Skip to content

Bug: Single channel ScanImage errors when channel_name is not specified #1585

@h-mayorquin

Description

@h-mayorquin
from neuroconv.datainterfaces import ScanImageImagingInterface
from pathlib import Path
import datetime as dt

file_path = Path("/Users/heberto/data/testing_data/ophys_testing_data/imaging_datasets/ScanImage/volumetric_single_channel_multi_file/vol_one_ch_multi_files_00001_00001.tif")
assert file_path.exists(), f"File path {file_path} does not exist."

date_time_now = dt.datetime.now()


interface = ScanImageImagingInterface(file_path=file_path, channel_name="")
metadata = interface.get_metadata()
metadata["NWBFile"]["session_start_time"] = date_time_now


nwbfile = interface.create_nwbfile(iterator_type=None, metadata=metadata)

Errors:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[11], [line 13](vscode-notebook-cell:?execution_count=11&line=13)
      9 date_time_now = dt.datetime.now()
     12 interface = ScanImageImagingInterface(file_path=file_path)
---> [13](vscode-notebook-cell:?execution_count=11&line=13) metadata = interface.get_metadata()
     14 metadata["NWBFile"]["session_start_time"] = date_time_now
     17 nwbfile = interface.create_nwbfile(iterator_type=None, metadata=metadata)

File ~/development/ccn-software-sfn-2025/.venv/lib/python3.12/site-packages/neuroconv/datainterfaces/ophys/scanimage/scanimageimaginginterfaces.py:193, in ScanImageImagingInterface.get_metadata(self)
    191 device_name = "Microscope"
    192 metadata["Ophys"]["Device"][0].update(name=device_name, description=f"Microscope controlled by ScanImage")
--> [193](https://file+.vscode-resource.vscode-cdn.net/Users/heberto/development/ccn-software-sfn-2025/notebooks/turner/~/development/ccn-software-sfn-2025/.venv/lib/python3.12/site-packages/neuroconv/datainterfaces/ophys/scanimage/scanimageimaginginterfaces.py:193) channel_name_string = self.channel_name.replace(" ", "").capitalize()
    195 optical_channel_name = f"OpticalChannel{channel_name_string}"
    196 optical_channel_metadata = {
    197     "name": optical_channel_name,
    198     "description": "Optical channel from ScanImage acquisition",
    199     "emission_lambda": np.nan,
    200 }

AttributeError: 'NoneType' object has no attribute 'replace'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions