Consolidate functions duplicated in ophys-slap2-analysis into GIAnT-MATLAB

Aperta
#36 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
matlab
Ambito
backend

Direzione di ricerca

Start by reviewing the inventory and proposed consolidation in this issue, then compare the named GIAnT-MATLAB and ophys-slap2-analysis entry points, especially setParams, optionsGUI, and the older summarize_LoCo pipeline. The issue leaves key decisions open about retiring or freezing that pipeline and choosing an annotation format. Done means the repositories no longer have unintended function-name collisions, their dependency and path setup is documented, and the proposed path-resolution test is in place.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

GIAnT-MATLAB started on 2026-03-23 by moving processing code out of ophys-slap2-analysis, but the originals stayed there. I compared the two main branches (GIAnT-MATLAB at c69d1db, ophys-slap2-analysis at AllenNeuralDynamics/ophys-slap2-analysis@8b89d18) by file name and by content. 31 GIAnT functions have a copy or an earlier version in ophys-slap2-analysis, and two more names differ from GIAnT's only by letter case.

This causes three problems:

  1. With both repos on the MATLAB path, one copy silently shadows the other. The worst case is setParams: the two copies have the same signature but disjoint case lists. Whichever is first on the path makes the other repo's stages fail with "Unknown function name passed to setParams.m".

  2. Fixes land in only one copy. GIAnT has:

    • the nansvd padding fix
    • the drawROIs circle-radius fix
    • an error instead of keyboard in the xcorr2_nans* functions

    ophys-slap2-analysis has the optionsGUI dialog-centering fix (AllenNeuralDynamics/ophys-slap2-analysis@2282dd1), and GIAnT does not.

  3. New copies are still being made. extractDendrites now carries readTrialTableH5, an inline copy of GIAnT's loadStructFromH5, so that it doesn't need GIAnT-MATLAB on the path.

Since the split, only four of these ophys-slap2-analysis files have changed: setParams, optionsGUI, postAcquisitionAnnotation and summarize_LoCo. Every other copy there is an older version of the GIAnT code.

Inventory

A. Identical. These can be deleted from ophys-slap2-analysis once GIAnT is on its path.

GIAnT-MATLAB ophys-slap2-analysis Files calling it in ophys-slap2-analysis
dependencies/alignment/dftregistration_clipped.m matlab/dependencies/dftregistration_clipped.m 8
dependencies/alignment/interpFrame.m matlab/dependencies/interpFrame.m 2
dependencies/alignment/interpFrames.m matlab/preprocessing/interpFrames.m 1
dependencies/alignment/slap2/bandscan/makeLookupTable.m matlab/slap2/Registration/Michael/makeLookupTable.m 2
dependencies/alignment/slap2/bandscan/poissonLogLikelihoodTable.m matlab/slap2/Registration/Michael/poissonLogLikelihoodTable.m 2
dependencies/alignment/slap2/getOnlineMotion.m matlab/slap2/Registration/getOnlineMotion.m 3
dependencies/io/loadMetadata.m matlab/slap2/loadMetadata.m 9

B. Same signature, and the GIAnT copy has fixes. The GIAnT copies are drop-in replacements.

GIAnT-MATLAB ophys-slap2-analysis What GIAnT changed Callers
dependencies/alignment/xcorr2_nans.m matlab/dependencies/xcorr2_nans.m error instead of keyboard when the motion is NaN 13
dependencies/alignment/xcorr2_nans3d.m matlab/dependencies/xcorr2_nans3d.m Same 1
dependencies/alignment/xcorr2_nans_weighted.m matlab/dependencies/xcorr2_nans_weighted.m Same, plus a faster version of the same arithmetic 1
dependencies/nansvd.m matlab/dependencies/nansvd.m Pads the outputs when svds returns fewer components than requested 3
dependencies/gui/drawROIs.m matlab/dependencies/drawROIs.m Circle ROIs keep their radius, closing the window keeps the ROIs, and the display image comes from annotationDisplayImage 6
dependencies/nanmedfilt2.m matlab/dependencies/nanmedfilt2.m Licence header and an error-message typo only 3
dependencies/alignment/makeConsensusTemplate.m matlab/slap2/Registration/makeTemplateMultiRoi.m Renamed only 6

C. Same name, diverged. These are stages of the older ophys-slap2-analysis pipeline, which uses trialTable.mat and .mat alignment files.

Function GIAnT-MATLAB ophys-slap2-analysis How they differ
buildTrialTableSLAP2 buildTrialTableSLAP2.m matlab/preprocessing/buildTrialTableSLAP2.m GIAnT takes (dr, savedr, useAllFiles) and writes trial_table.h5; ophys-slap2-analysis takes (dr) and writes trialTable.mat
verifyFiles dependencies/verifyFiles.m matlab/preprocessing/verifyFiles.m ophys-slap2-analysis takes an extra params argument
loadAndProcessTrialAsync dependencies/extraction/activityImage/ matlab/preprocessing/ GIAnT takes the motion_correction folder and reads the H5 alignment layout
localizeSources_vIM dependencies/extraction/activityImage/ matlab/preprocessing/ Different first output (skIm vs summaryEroded)
processAllTrials_Async dependencies/extraction/ matlab/preprocessing/ Same signature; GIAnT expects the H5 alignment layout (alignData.slap2) and reads frames only at the sampled pixels
extractTrial dependencies/extraction/ matlab/preprocessing/ GIAnT takes an extra alignData argument
setParamsExtractTrial dependencies/extraction/ matlab/preprocessing/ The parameter sets have diverged

D. Same name, different function (collisions)

Name GIAnT-MATLAB ophys-slap2-analysis Notes
setParams dependencies/gui/setParams.m, with cases SILo, MultiRoiRegistration, BandRegistration, StripRegistration matlab/dependencies/setParams.m, with cases summarize_NoLoCo, summarize_LoCo, multiRoiRegSLAP2, integrationRegistration, stripRegBergamo, extractDendrites, summarize_Voltage Whichever comes first on the path breaks the other repo. 14 files in ophys-slap2-analysis call it.
optionsGUI dependencies/gui/optionsGUI.m matlab/dependencies/optionsGUI.m The copies have diverged substantially; only ophys-slap2-analysis has the centering fix.
postAcquisitionAnnotation utils/postAcquisitionAnnotation.m: (dr, fns), writes postacq_annotations.h5 for importPostAcqAnnotations matlab/slap2/postAcquisition/postAcquisitionAnnotation.m: (dr), its output is read by summarize_LoCo Two implementations of the same step at the rig, writing different formats
ScanImageTiffReader dependencies/io/ScanImageTiffReader.m (a MATLAB class) matlab/dependencies/+ScanImageTiffReader/ (MEX package) Two different readers under one name
MultiRoiRegistration / multiRoiRegistration motion_correction/MultiRoiRegistration.m matlab/slap2/Registration/multiRoiRegistration.m (old, no callers) The names differ only in case, which is fragile on Windows and macOS
StripRegistration / stripRegistration motion_correction/StripRegistration.m matlab/bergamo/stripRegistration.m (old, no callers) Same

E. Renamed copies. These are the ophys-slap2-analysis originals of GIAnT functions.

GIAnT-MATLAB ophys-slap2-analysis Content similarity
motion_correction/MultiRoiRegistration.m matlab/preprocessing/multiRoiRegSLAP2.m 0.75
motion_correction/StripRegistration.m matlab/preprocessing/stripRegBergamo.m 0.74
motion_correction/BandRegistration.m matlab/slap2/Registration/Michael/integrationRegistration.m 0.76
buildTrialTable.m matlab/preprocessing/buildTrialTableBergamo.m 0.54
dependencies/alignment/shiftRoiData.m Local function in matlab/preprocessing/summarize_LoCo.m
dependencies/io/loadStructFromH5.m Local readTrialTableH5 in matlab/slap2/Voltage/extractDendrites.m

Proposed consolidation

  1. Bring into GIAnT the one fix that exists only in ophys-slap2-analysis: the optionsGUI centering fix (AllenNeuralDynamics/ophys-slap2-analysis@2282dd1).

  2. Make GIAnT-MATLAB a declared dependency of ophys-slap2-analysis, in its README and with a helper that sets up the path. Then:

    • Delete groups A and B from ophys-slap2-analysis.
    • Point the 6 callers of makeTemplateMultiRoi at makeConsensusTemplate.

    One behaviour changes for ophys-slap2-analysis callers: the xcorr2_nans* functions throw an error on NaN motion instead of stopping in keyboard.

  3. Remove the collisions in group D:

    • setParams: rename the ophys-slap2-analysis copy, which only configures ophys-slap2-analysis functions, or merge both sets of cases into the GIAnT copy.
    • optionsGUI: delete the ophys-slap2-analysis copy after step 1.
    • postAcquisitionAnnotation: settle on one output format. If summarize_LoCo can read postacq_annotations.h5, delete the ophys-slap2-analysis copy.
    • multiRoiRegistration.m and bergamo/stripRegistration.m: delete them, since nothing calls them.
    • ScanImageTiffReader: check that ophys-slap2-analysis calls to ScanImageTiffReader.ScanImageTiffReader still reach the MEX package when GIAnT is on the path.
  4. Decide what happens to the older pipeline in groups C and E (multiRoiRegSLAP2 / stripRegBergamo → summarize_LoCo). It still uses its own copies and the .mat layouts, and summarize_LoCo changed as recently as 2026-08-25, so it is still in use. There are two options:

    • Retire it in favour of MultiRoiRegistration / StripRegistration → SILo, and keep in ophys-slap2-analysis only the analyses that GIAnT doesn't have, such as extractDendrites and the voltage analysis.
    • Freeze it, and rename its internals so they no longer shadow GIAnT's.
  5. Replace the inline readTrialTableH5 in extractDendrites with loadStructFromH5.

To keep the repos from drifting apart again, add a test that runs with both repos on the path and fails when any function name resolves to more than one file (which -all).

How the inventory was made. Each non-test .m file in GIAnT-MATLAB was matched against every .m file in ophys-slap2-analysis, by file name (ignoring case) and by content similarity (difflib ratio on non-comment lines). Local functions defined in both repos were listed as well. Third-party code bundled in ophys-slap2-analysis (NoRMCorre, OASIS, Fast_Tiff_Write) is out of scope.

Lingua principale
MATLAB
Stelle
3
Fork
3
Merge medio
1g 22h
PR unite (30g)
31

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AllenNeuralDynamics/GIAnT-MATLAB

Tutte le issue di AllenNeuralDynamics/GIAnT-MATLAB

Issue simili

Altre issue su MATLAB

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.