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 included ROIs from fiber locations #16

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions src/howe_lab_to_nwb/vu2024/utils/add_fiber_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def add_fiber_photometry_table(nwbfile: NWBFile, metadata: dict):
description="The fiber tip coordinates (AP, ML, DV) in Allen Brain Atlas coordinates",
)
fiber_photometry_table.add_column(
name="is_good_fiber",
name="included",
description="Whether this fiber has been successfully implanted.",
)

Expand Down Expand Up @@ -180,9 +180,9 @@ def add_fiber_photometry_series(
if default_series_name not in nwbfile.acquisition:
for fiber_ind in range(num_fibers):
brain_area = fiber_locations_metadata[fiber_ind]["location"]
is_good_fiber = True if brain_area else False
included = fiber_locations_metadata[fiber_ind]["included"]
fiber_photometry_table.add_row(
is_good_fiber=is_good_fiber,
included=included,
location=brain_area, # TODO: change this in the extension to brain_area
coordinates=fiber_locations_metadata[fiber_ind]["coordinates"],
allen_atlas_coordinates=fiber_locations_metadata[fiber_ind]["allen_atlas_coordinates"],
Expand Down Expand Up @@ -264,6 +264,7 @@ def get_fiber_locations(file_path: FilePathType) -> List[dict]:
allen_atlas_coordinates=allen_atlas_coordinates,
# TODO: rename to brain_area
location=brain_area,
included=row["included"],
)
fibers_metadata.append(fiber_metadata)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Union, Optional, List

from dateutil import tz
from neuroconv.tools.nwb_helpers import configure_and_write_nwbfile
from neuroconv.utils import load_dict_from_file, dict_deep_update
from pynwb import NWBFile

Expand Down Expand Up @@ -118,7 +119,7 @@ def single_wavelength_session_to_nwb(
)

# Add ROI segmentation
accepted_list = [fiber_ind for fiber_ind, fiber in enumerate(fiber_locations_metadata) if fiber["location"] != ""]
accepted_list = [fiber_ind for fiber_ind, fiber in enumerate(fiber_locations_metadata) if fiber["included"]]
roi_source_data = dict(
file_path=str(raw_fiber_photometry_file_path),
sampling_frequency=sampling_frequency,
Expand Down Expand Up @@ -209,13 +210,7 @@ def single_wavelength_session_to_nwb(
if nwbfile_path is None:
return nwbfile

converter.run_conversion(
nwbfile_path=nwbfile_path,
nwbfile=nwbfile,
metadata=metadata,
conversion_options=conversion_options,
overwrite=True,
)
configure_and_write_nwbfile(nwbfile=nwbfile, output_filepath=nwbfile_path)


if __name__ == "__main__":
Expand Down
Loading