Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _roi_response_denoised to store denoised traces #291

Merged
merged 16 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/build_re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ To build a custom SegmentationExtractor that interfaces with the output of a cus
self._roi_response_raw = self._load_traces()# define a method to extract Flourescence traces
self._roi_response_dff = self._load_traces()# define a method to extract dF/F traces if any else None
self._roi_response_neuropil = self._load_traces()# define a method to extract neuropil info if any else None
self._roi_response_denoised = self._load_traces() # define a method to extract denoised traces if any else None
self._roi_response_deconvolved = self._load_traces() # define a method to extract deconvolved traces if any else None
self._image_correlation = self._load_summary_images()# define method to extract a correlation image else None
self._image_mean = self._load_summary_images() # define method to extract a mean image else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __init__(self, file_path: PathType):
self.file_path = file_path
self._dataset_file = self._file_extractor_read()
self._roi_response_dff = self._trace_extractor_read("F_dff")
self._roi_response_neuropil = self._trace_extractor_read("C")
self._roi_response_denoised = self._trace_extractor_read("C")
self._roi_response_neuropil = self._trace_extractor_read("b")
Copy link

@EricThomson EricThomson Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I'm just in here poking around your PR 😄 It looks great 🚀

I think you probably want f here for neuropil for the trace_extractor() method (that's the background fluctuations). b is the background spatial component(s) that would correspond for instance to A for the neural components. Forgive me if I've misunderstood how things work I'm pretty new to NWB.

I'm thinking it's just a typo (our variable names are awful, b/f what do those mean? 😆 ), as f is what you noted in the original issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @EricThomson. I am now trying include the spatial component "b" as well.

self._roi_response_deconvolved = self._trace_extractor_read("S")
self._image_correlation = self._summary_image_read()
self._sampling_frequency = self._dataset_file["params"]["data"]["fr"][()]
Expand Down Expand Up @@ -177,8 +178,10 @@ def write_segmentation(segmentation_object, save_path, overwrite=True):
estimates = f.create_group("estimates")
params = f.create_group("params")
# adding to estimates:
if segmentation_object.get_traces(name="denoised") is not None:
estimates.create_dataset("C", data=segmentation_object.get_traces(name="denoised"))
if segmentation_object.get_traces(name="neuropil") is not None:
estimates.create_dataset("C", data=segmentation_object.get_traces(name="neuropil"))
estimates.create_dataset("b", data=segmentation_object.get_traces(name="neuropil"))
if segmentation_object.get_traces(name="dff") is not None:
estimates.create_dataset("F_dff", data=segmentation_object.get_traces(name="dff"))
if segmentation_object.get_traces(name="deconvolved") is not None:
Expand Down
4 changes: 3 additions & 1 deletion src/roiextractors/segmentationextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self):
self._roi_response_raw = None
self._roi_response_dff = None
self._roi_response_neuropil = None
self._roi_response_denoised = None
self._roi_response_deconvolved = None
self._image_correlation = None
self._image_mean = None
Expand Down Expand Up @@ -223,13 +224,14 @@ def get_traces_dict(self):
-------
_roi_response_dict: dict
dictionary with key, values representing different types of RoiResponseSeries:
Fluorescence, Neuropil, Deconvolved, Background, etc.
Raw Fluorescence, DeltaFOverF, Denoised, Neuropil, Deconvolved, Background, etc.
"""
return dict(
raw=self._roi_response_raw,
dff=self._roi_response_dff,
neuropil=self._roi_response_neuropil,
deconvolved=self._roi_response_deconvolved,
denoised=self._roi_response_denoised,
)

def get_images_dict(self):
Expand Down
2 changes: 1 addition & 1 deletion src/roiextractors/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def check_segmentation_return_types(seg: SegmentationExtractor):
)
assert isinstance(seg.get_traces_dict(), dict)
assert isinstance(seg.get_images_dict(), dict)
assert {"raw", "dff", "neuropil", "deconvolved"} == set(seg.get_traces_dict().keys())
assert {"raw", "dff", "neuropil", "deconvolved", "denoised"} == set(seg.get_traces_dict().keys())


def check_imaging_equal(
Expand Down
Loading