simply_nwb package
Subpackages
- simply_nwb.pipeline package
- simply_nwb.transferring package
- simply_nwb.transforms package
- Submodules
- simply_nwb.transforms.blackrock module
- simply_nwb.transforms.csv module
- simply_nwb.transforms.eyetracking module
- simply_nwb.transforms.labjack module
- simply_nwb.transforms.mp4 module
- simply_nwb.transforms.neuropixels module
- simply_nwb.transforms.p_erg module
- simply_nwb.transforms.plaintext module
- simply_nwb.transforms.tif module
- simply_nwb.transforms.yaml module
- Module contents
Submodules
simply_nwb.simple_nwb module
- class simply_nwb.simple_nwb.SimpleNWB
Bases:
_TIFMixin,_MP4Mixin,_LabjackMixin,_BlackrockMixin,_PergMixin,_EyetrackingMixin,object- static add_to_processing_module(nwbfile: NWBFile, data: Any, module_name: str | None = None, module_description: str | None = None) NWBFile
Add data to a processing module, automatically creating it if it doesn’t already exist
- Parameters:
nwbfile – NWBFile to add the data to
module_name – Name of the processing module to create or use
module_description – Description of the module, if not provided will be auto generated
data – Data to be added to the processing module
- Returns:
NWBFile
- static create_nwb(session_description: str, session_start_time: ~datetime.datetime, experimenter: [<class 'str'>], lab: str, experiment_description: str, institution: str, identifier: str | None = None, subject: ~pynwb.file.Subject | None = None, session_id: str | None = None, keywords: list[str] | None = None, related_publications: str | None = None) NWBFile
Create a new nwbfile from the given params. More infor here https://pynwb.readthedocs.io/en/stable/pynwb.file.html#pynwb.file.NWBFile
- Parameters:
session_description – description of the session
session_start_time – start date and time of recording session
experimenter – name of experimenter, list of form [“Lastname, Firstname”]
lab – name of lab
experiment_description – experiment description
institution – institution
identifier – Optional identifier for the file, if not supplied will be generated
subject – Optional pynwb.file.Subject object for metadata
session_id – Optional lab-specific session id, if not supplied will be generated
keywords – Optional list of keywords e.g [“keyword1”, “keyword2”, …]
related_publications – Optional related publications in a list of the DOI, URL, PMID etc [“DOI:1234/asdf”]
- Returns:
NWBFile
- static inspect_filename(nwbfilename: str) list[Any]
Inspect the given NWBFile from filename
- Parameters:
nwbfilename – filename to the NWB
- Returns:
List of issues with the file, if empty, inspection passed
- static inspect_obj(nwbfile: NWBFile) list[Any]
Inspect the given NWBFile object
- Parameters:
nwbfile – NWBFile object
- Returns:
List of issues with the file, if empty, inspection passed
- static processing_add_dataframe(nwbfile: NWBFile, processed_name: str, processed_description: str, data: DataFrame) NWBFile
Add a processed pandas Dataframe into the NWB that doesn’t fit in any other part of the NWB. MAKE SURE YOU CANNOT ADD IT ELSEWHERE BEFORE USING THIS FUNC!
- Parameters:
nwbfile – NWBFile to add data to
processed_name – Name of the processing module
processed_description – description of the processed data
data – Pandas Dataframe data to add
- Returns:
NWBFile
- static processing_add_dict(nwbfile: NWBFile, processed_name: str, data_dict: dict, processed_description: str, processing_module_name: str | None = None, uneven_columns: bool = False) NWBFile
Add a processed dict into the NWB that doesn’t fit in any other part of the NWB. MAKE SURE YOU CANNOT ADD IT ELSEWHERE BEFORE USING THIS FUNC!
- Parameters:
nwbfile – NWBFile to add data to
processing_module_name – Name of the processing module to add the data to. If not set will default to ‘misc’
processed_name – Name of the dynamic table
processed_description – description of the processed data
data_dict – dict data to add
uneven_columns – Set this to True if the keys of the dict have different lengths
- Returns:
NWBFile
- static test_nwb() NWBFile
Generate a dummy nwb object to test with
- Returns:
test nwb object
- static two_photon_add_data(nwbfile: NWBFile, device_name: str, device_description: str, device_manufacturer: str, optical_channel_description: str, optical_channel_emission_lambda: float, imaging_name: str, imaging_rate: float, excitation_lambda: float, indicator: str, location: str, grid_spacing: list[float], grid_spacing_unit: str, origin_coords: list[float], origin_coords_unit: str, two_photon_unit: str, two_photon_rate: float, photon_series_name: str, image_data: Any) NWBFile
Add images from a two photon microscope to an NWB with metadata. Load TIF images easily with the simply_nwb.acquisition.tools.tif module
- Parameters:
nwbfile – NWBFile to add the data to
device_name – Name of the microscope e.g. MyMicroscope1
device_description – Description of the microscope
device_manufacturer – Manufacturer of the microscope
optical_channel_description – Description of the optical channel, electrode name
optical_channel_emission_lambda – Emission wavelength for optical channel, in nm
imaging_name – Name of this imaging dataset e.g ‘my_images’
imaging_rate – Rate at which images were acquired, in Hz
excitation_lambda – Excitation wavelength in nm
indicator – Indicator, e.g. GFP
location – Location, e.g. V1
grid_spacing – Spacing of the grids used e.g. [0.1, 0.1]
grid_spacing_unit – Unit of the grid spacing e.g. ‘meters’
origin_coords – Coords of the origin e.g. [0.1, 0.2] or for 3d data [0.1, 0.2, 0.3]
origin_coords_unit – Unit of the origin coords
two_photon_unit – Unit for the photon microscope, e.g. ‘normalized amplitude’
two_photon_rate – two photon sampling rate in Hz
photon_series_name – Name of the two photon series for storage
image_data – Numpy array of the data in shape (samples, xres, yres, channels) if only one channel, can omit
- Returns:
NWBFile
- static write(nwbfile: NWBFile, filename: str, verify_on_write: bool | None = True) NWBFile
Write the give NWBFile object to file
- Parameters:
nwbfile – NWBFile object to write
filename – path to file to write, WILL OVERWRITE!
verify_on_write – Verify that most fields wrote correctly and the file didn’t corrupt
- Returns:
NWBFile
simply_nwb.util module
- simply_nwb.util.age_str_from_birthday(birthday_str: str) str
Create a ISO-8601 Period date string from a birthday. Interprets most date formats correctly, to ensure correct behavior, format ‘MM-DD-YYYY’ is recommended
- Parameters:
birthday_str – String of birthday
- simply_nwb.util.compare_nwbfiles(nwbfile1: NWBFile, nwbfile2: NWBFile, name1: str, name2: str)
Compare two nwbfiles, checking that they contain the same things, only check a handful of fields TODO? This is useful when writing a file, want to ensure all our fields that successfully wrote are read in correctly. If there is a difference, will throw a ValueError
- Parameters:
nwbfile1 – NWBFile 1 to compare
nwbfile2 – NWBFile 2 to compare
name1 – String name of NWBFile 1, used in error message only
name2 – String name of NWBFile 2, used in error message only
- simply_nwb.util.create_mouse_subject(subject_id: str, birthday_str: str, strain: str, sex: str, desc: str) Subject
Create a Subject object, simple wrapper
- Parameters:
subject_id – ID to use to uniquely identify a mouse
birthday_str – String of birthday of the mouse
strain – Strain of the mouse
sex – Mouse sex
desc – Description of the mouse
- simply_nwb.util.date_to_mouse_age(date_str: str | None) str | None
Convert a date into an ISO-8601 period time value
- Parameters:
date_str – string of the date, should be pendulum parsable
- Returns:
string like ‘P90D’
- simply_nwb.util.dict_to_dyn_tables(dict_data: dict, table_name: str, description: str, multiple_objs: bool = True) DynamicTable
Util function to transform a python dict into a DynamicTable object If keys are not the same length, set multiple_objs=True
- Parameters:
dict_data – Dict to add
table_name – name of the table
description – description of the table
multiple_objs – set to true if the columns are uneven
- Returns:
DynamicTable
- simply_nwb.util.inspect_nwb_file(filename: str) list[Any]
Return the inspection list of a given NWB file
- Parameters:
filename – filename of the NWB to inspect
- Returns:
list of inspection objects for the given NWB, if empty, no issues found
- simply_nwb.util.inspect_nwb_obj(obj: NWBFile) list[Any]
Return the inspection list of a given NWB object
- Parameters:
obj – NWBFile object to inspect
- Returns:
list of inspection objects, if empty no issues were found
- simply_nwb.util.is_camel_case(string: str, do_print: bool = True) bool
Check if the given string is in CamelCase
- Parameters:
string – string to check
do_print – if False, will not print out anything
- Returns:
bool if str is CamelCase
- simply_nwb.util.is_filesystem_safe(string: str) bool
Generic check function for if a string is filesystem safe, limits to a-z A-Z 0-9 ‘_’ ‘-’
- Parameters:
string – String to check
- Returns:
True if the given string matches the regex
- simply_nwb.util.is_snake_case(string: str, do_print: bool = True) bool
Checks if the given string is snake_case
- Parameters:
string – string to check if is snake_case
do_print – if False, will not print anything
- Returns:
bool of if the string is snake_case
- simply_nwb.util.nwb_write(nwb_obj: NWBFile, filename: str, verify: bool)
Write an NWB object to a file on the local filesystem, and verify the contents were written correctly and the file isn’t corrupted
- Parameters:
nwb_obj – pynwb.file.NWBFile object
filename – path of a local file, doesn’t need to exist
verify – Verify that most fields wrote correctly and the file didn’t corrupt
- Returns:
None
- simply_nwb.util.panda_df_to_dyn_table(pd_df: DataFrame, table_name: str, description: str) DynamicTable
Util function to transform a pandas DataFrame into a DynamicTable object
- Parameters:
pd_df – Pandas DataFrame
table_name – name of the table
description – description of the table
- Returns:
DynamicTable
- simply_nwb.util.panda_df_to_list_of_timeseries(pd_df: DataFrame, measured_unit_list: list[str], start_time: float, sampling_rate: float, description: str, series_name_prefix: str = '', comments: str | None = None) list[TimeSeries]
Turns a panda dataframe into a list of TimeSeries objects
- Parameters:
pd_df – dataframe to transform
measured_unit_list – list of units for each column of the dataframe
series_name_prefix – optional series prefix
start_time – time the data started for each timeseries
sampling_rate – sampling rate in Hz
description – description of this dataframe
comments – optional comments
- Returns:
- simply_nwb.util.warn_on_name_format(name_value: str, context_str: str = '') bool
Send a warning if the name format isn’t in ‘snake_case’
- Parameters:
name_value – value to check
context_str – Extra string to put in warning message
- Returns:
True if passes, False otherwise