AllenInstitute / AllenSDK

code for reading and processing Allen Institute for Brain Science data
https://allensdk.readthedocs.io/en/latest/
Other
333 stars 149 forks source link

Error reading NWB file while session cache is instantiated in workspace #2693

Open slcalgin opened 1 year ago

slcalgin commented 1 year ago

Hi there, I'm working on a script that downloads data from Neuropixels dataset using the EcephysProjectCache. Below is how I download the data from sessions - no problem here, just for reference:

self.cache = EcephysProjectCache.from_warehouse(manifest=manifest_path)
self.session = self.cache.get_session_data(self.session_id)

In this script I want to be able to use the API to access data, but also want to be able to read and write to the NWB file. However, when I go to open the NWB file:

with NWBHDF5IO(nwbfilepath, mode="r+", load_namespaces=True) as io:
     io.read(path_to_nwb)

I get the following error: OSError: Unable to open file (file is already open for read-only).

I have confirmed that the file is not open elsewhere in my code or device. I'm assuming that the session cache has the file open in the backend somewhere in order to access the data. But I'm not sure why this is necessary if the NWBFileobject is already stored within the session object (session.api.nwbfile). Would this be correct? Do you know of a way to workaround this?

Thanks!