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 ThorTiffImagingInterface #846

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions docs/api/interfaces.ophys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ ScanImage Imaging
-----------------
.. automodule:: neuroconv.datainterfaces.ophys.scanimage.scanimageimaginginterfaces

ThorLabs Imaging
----------------
.. automodule:: neuroconv.datainterfaces.ophys.thor.thorimaginginterface

Tiff Imaging
------------
.. automodule:: neuroconv.datainterfaces.ophys.tiff.tiffdatainterface
Expand Down
29 changes: 29 additions & 0 deletions docs/conversion_examples_gallery/imaging/thor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ThorLabs data conversion
------------------------

Install NeuroConv with the additional dependencies necessary for reading ThorLabs imaging data.

.. code-block:: bash

pip install neuroconv[thor]

Convert single plane single file imaging data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Convert ScanImage imaging data to NWB using
:py:class:`~neuroconv.datainterfaces.ophys.thor.thorimaginginterface`.

.. code-block:: python

>>> from datetime import datetime
>>> from dateutil import tz
>>> from pathlib import Path
>>> from neuroconv.datainterfaces import ThorTiffImagingInterface
>>>
>>> file_path = OPHYS_DATA_PATH / "imaging_datasets" / "ThorLabs" / "data"
>>> interface = ThorTiffImagingInterface(folder_path=folder_path)
>>>
>>> metadata = interface.get_metadata()
>>>
>>> # Choose a path for saving the nwb file and run the conversion
>>> interface.run_conversion(nwbfile_path=f"{path_to_save_nwbfile}", metadata=metadata)
2 changes: 2 additions & 0 deletions src/neuroconv/datainterfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
)
from .ophys.sima.simadatainterface import SimaSegmentationInterface
from .ophys.suite2p.suite2pdatainterface import Suite2pSegmentationInterface
from .ophys.thor.thorimaginginterface import ThorTiffImagingInterface
from .ophys.tiff.tiffdatainterface import TiffImagingInterface

# Text
Expand Down Expand Up @@ -138,6 +139,7 @@
ExtractSegmentationInterface,
SimaSegmentationInterface,
SbxImagingInterface,
ThorTiffImagingInterface,
TiffImagingInterface,
Hdf5ImagingInterface,
ScanImageImagingInterface,
Expand Down
Empty file.
1 change: 1 addition & 0 deletions src/neuroconv/datainterfaces/ophys/thor/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
roiextractors[thor]
40 changes: 40 additions & 0 deletions src/neuroconv/datainterfaces/ophys/thor/thorimaginginterface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from roiextractors.extractors.thorextractors.thorimagingextractor import (
ThorTiffImagingExtractor,
)

from neuroconv.datainterfaces.ophys.baseimagingextractorinterface import (
BaseImagingExtractorInterface,
)
from neuroconv.utils import DeepDict, FilePathType


class ThorTiffImagingInterface(BaseImagingExtractorInterface):
"""Interface for multi-page TIFF files from the ThorLabs acquisition system."""

display_name = "ThorLabs TIFF Imaging"
Extractor = ThorTiffImagingExtractor

@classmethod
def get_source_schema(cls) -> dict:
source_schema = super().get_source_schema()
source_schema["properties"]["folder_path"]["description"] = (
"Directory that contains the TIFF files and " "Experiment.xml file. "
)
return source_schema

def __init__(self, folder_path: FilePathType, verbose: bool = False):
"""
Initialize reading of TIFF file.

Parameters
----------
folder_path : FilePathType
Directory that contains the TIFF files and Experiment.xml file.
verbose : bool, default: False
"""
super().__init__(folder_path=folder_path, verbose=verbose)

def get_metadata(self, photon_series_type="TwoPhotonSeries") -> DeepDict:
metadata = super().get_metadata(photon_series_type=photon_series_type)
metadata["NWBFile"]["session_start_time"] = self.extractor.start_time
return metadata
Loading