Open TheChymera opened 1 year ago
metadata = dict(Subject=dict(subject_id="my_subject_name", sex="M_F_U_or_O", species="Mus musculus - or w/e else", age="P1W - be sure to use ISO 8601"))
Should work using structure as seen above
@CodyCBakerPhD doesn't seem to work:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/chymera/src/neuralynx_nwb/neuralynx_nwb/newconvert.py", line 197, in reposit_data
_m = dict(Subject(subject_id=metadata["subject"], species="Mus musculus"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'Subject' object is not iterable
Also, just to check that I understand:
pynwb.file.Subject
object?Here is a demonstration of working code that passes the subject metadata into the file
Uses test file found here
from datetime import datetime
from dateutil import tz
from pathlib import Path
from neuroconv.datainterfaces import SpikeGLXRecordingInterface
# For this interface we need to pass the location of the ``.bin`` file
file_path = f"E:/GIN/ephy_testing_data/spikeglx/Noise4Sam_g0/Noise4Sam_g0_imec0/Noise4Sam_g0_t0.imec0.ap.bin"
# Change the file_path to the location in your system
interface = SpikeGLXRecordingInterface(file_path=file_path, verbose=False)
# Extract what metadata we can from the source files
metadata = interface.get_metadata()
# For data provenance we add the time zone information to the conversion
session_start_time = metadata["NWBFile"]["session_start_time"].replace(tzinfo=tz.gettz("US/Pacific"))
metadata["NWBFile"].update(session_start_time=session_start_time)
metadata["Subject"]["subject_id"] = "This is a subject ID."
# Choose a path for saving the nwb file and run the conversion
nwbfile_path = f"C:/Users/Raven/Downloads/test_subject.nwb"
interface.run_conversion(nwbfile_path=nwbfile_path, metadata=metadata)
Ah, sorry, ok, I misunderstood the syntax. For some reason I though that Subject
was supposed to be an object.
I create a dictionary containing a “subject” key with a string value (here) and pass it to
interface.run_conversion()
via the metadata argument.Sadly, when I check the file, it says the required subject field is missing → https://ppb.chymera.eu/6a464d.txt @CodyCBakerPhD Any idea how I could structure the dictionary so that that works?