catalystneuro / roiextractors

Python-based module for extracting from, converting between, and handling optical imaging data from several file formats. Inspired by SpikeInterface.
https://roiextractors.readthedocs.io/en/latest/index.html
BSD 3-Clause "New" or "Revised" License
12 stars 7 forks source link

[Bug]: Background Components are mixed up in CaimanSegmentationExtractor #249

Closed pauladkisson closed 8 months ago

pauladkisson commented 1 year ago

Expected Behavior

According to the CaImAn docs, estimates.C refers to the 'temporal components', which should be stored as _roi_response_raw in the SegmentationExtractor and estimates.f refers to the 'temporal background components', which should be stored as _roi_response_neuropil in the SegmentationExtractor.

Current Behavior

Instead, in the CaimanSegmentationExtractor,

self._roi_response_neuropil = self._trace_extractor_read("C")

and estimates.f is ignored.

Code of Conduct

EricThomson commented 9 months ago

Hi Caiman maintainer here. I've started working on Caiman -> NWB integration, and improving our save_nwb() functionality as initially discussed here: https://github.com/flatironinstitute/CaImAn/issues/1146

I think this problem happens only if you use our current old and wonky save nwb function, which we will deprecate soon.

The next iteration I am planning to just lean on neuronconv. I've been playing around with neuroconv today with the CNMF bits, and the conversion works fine as it just pulls in the denoised calcium traces in estimates.C, the deltaf/F in estimates.F_dff, and the the deconvolved traces (spike count estimates) in estimates.S. The numbers all line up fine.

So, I think you can safely close this issue as it isn't a problem on your end but a problem we were introducing into the world with our poorly designed nwb save function.

pauladkisson commented 9 months ago

Good to hear from you @EricThomson! I just want to double check -- are you using the CnmfeSegmentationInterface or the CaimanSegmentationInterface? Bc I believe this issue is only for the caiman one.

EricThomson commented 9 months ago

Hi I'm using the CaimanSegmentationInterface, basically following the example here:
https://neuroconv.readthedocs.io/en/main/conversion_examples_gallery/segmentation/caiman.html