Repository navigation
Correctness fixes: no eval on file content, readrawfile rewrite, dead code - #2
Open
ehennestad wants to merge 2 commits into
Open
ehennestad wants to merge 2 commits into
ehennestad wants to merge 2 commits into
Conversation
readrawfile is rewritten from scratch: an arguments block with Channel, SkipFrames and NumFrames, the frame count derived from the file size instead of a try/catch around every fread, one fread per request with a block-skip for a single channel, typed errors for a missing .ini, unsupported file.format, no recorded channels and an invalid channel, and a warning when fewer frames are available than requested. The old version built its arrays through eval, modified its loop index inside the loop and opened a file dialog when called without a path. readinivar is now the single INI reader (SciScanRaw's static method delegates to it). It matches whole variable names at the start of a line, returns TRUE/FALSE as logicals and numbers as doubles, and never evaluates file text. SciScanRaw also loses an empty readFrameSet placeholder; readFrames is the VirtualArray API. Covered by SciScanRawFileTest on synthetic .raw/.ini recordings in both sample types. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…move dead code
- getParameterValueFromString parses the literal subset ScanImage writes
(numbers, strings, logicals, bracketed arrays, cell arrays, size
constructors) and returns anything else as text with a warning, so a
TIFF tag can no longer execute code. Covered by
ScanImageParameterParsingTest.
- TwoPhotonRecording documents the members it needs from its host class
(VirtualArray defines them with type validation, so they cannot be
declared abstract in the mixin).
- Unreachable code removed: the never-taken branches in MotionCorrection
(image statistics are always computed up front; reference update after
drift is not implemented), the abandoned frame-count algorithm behind a
return in ScanImageTiff, the if 1/else in the suite2p segmentation, and
the debug plotting blocks, the unused showDetectedEdges function and a
try/catch that printed 'a' in FluFinder's edge detection and shape
detection.
- improveRoiMasks drops its never-implemented second output.
- roi.stats.roiEdgyness (a template stub whose function was named
computeRoi) and roi.extractDff (error('Deprecated') with a
commented-out body) are deleted; neither had callers.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
Test Results78 tests 77 ✅ 5s ⏱️ Results for commit 6c5040b. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Batch R1 from the module review: correctness fixes, stacked on #1. Two commits: the
readrawfilerewrite with the INI reader, and the rest.readrawfilerewritten from scratchThe old function built its arrays through
eval, changed its loop index inside the loop, opened a file dialog when called without a path, and stopped at the end of the file by catchingfreaderrors. The new one has an arguments block (Channel,SkipFrames,NumFrames), derives the frame count from the file size, reads with onefreadper request (a block-skip for a single channel), raises typed errors for a missing.ini, an unsupportedfile.format, no recorded channels and an invalid channel, and warns when fewer frames are available than requested. Output layout is unchanged: x-by-y-by-frames(-by-channels) in the file's sample type.readinivaris now the single INI reader (the static method onSciScanRawdelegates to it): it matches whole variable names at line start, returns logicals for TRUE/FALSE and doubles for numbers, and evaluates nothing.SciScanRawFileTestcovers both sample types, channel selection, skip and count, truncation, the error paths and the INI typing. The function has no callers in NANSEN or the module today; it is kept as a public utility.Other fixes
evalon file content.getParameterValueFromStringparses the literal subset ScanImage writes (numbers, strings, logicals, bracketed arrays, cell arrays,zeros(1,0)-style constructors) and returns anything else as text with a warning, so a TIFF tag can no longer execute code.ScanImageParameterParsingTestcovers 25 literal forms and the fallbacks.TwoPhotonRecordingdocuments that its host must be aVirtualArrayand which members it uses. Declaring them abstract in the mixin is not possible: MATLAB rejects an abstract declaration of a property that another superclass defines with a type constraint.MotionCorrection(statistics are always computed up front; updating the reference image after drift correction is not implemented, now stated in a comment), the abandoned frame-count algorithm behind areturninScanImageTiff, theif 1 / elsein both suite2p segmentation functions, and FluFinder's debug plotting blocks, the unusedshowDetectedEdgesfunction and atry/catchthat printed'a'.improveRoiMasksdrops its never-implemented second output.SciScanRawloses an emptyreadFrameSetplaceholder (readFramesis the base-class API).roi.stats.roiEdgynesswas a template stub whose function was namedcomputeRoi;roi.extractDffwaserror('Deprecated')over a commented-out body.Not changed: the ScanImage
getScanParameterswarning-state item from the review was a false positive of my scan; that function restores the state. Thecnmfand legacyextract/ImviewerPluginsites flagged by the analyzer are dead code for the deletion batch.🤖 Generated with Claude Code