allensdk.brain_observatory.vbn_2022.input_json_writer.utils module

class allensdk.brain_observatory.vbn_2022.input_json_writer.utils.NwbConfigErrorLog[source]

Bases: object

This is a class meant to keep track of all of the non-fatal data irregularities encountered during input json generation for the VBN NWB writer.

log(ecephys_session_id: int | str, msg: str) None[source]

Log an irregularity associated with a specifiec ecephys session

Parameters:
ecephys_session_id: Union[int, str]

Will get cast to int before actual logging

msg: str

The specific message that you want attached to that ecephys_session_id

write() str[source]

Returns a string summarizing all of the logged message. The string will look like

ecephys_session: 1111

first message associated with ecephys_session 1111 second message assocated with ecephys_session 1111

ecephys_session: 2222

first message associated with ecephys_session 2222 …

allensdk.brain_observatory.vbn_2022.input_json_writer.utils.channel_input_from_ecephys_session_id(ecephys_session_id: int, probe_ids_to_skip: List[int] | None, lims_connection: PostgresQueryMixin, error_log: NwbConfigErrorLog) Dict[int, list][source]

Get a dict mapping probe_id to the list of channel specifications for a given ecephys_session_id

Parameters:
ecephys_session_id: int
probe_ids_to_skip: Optional[List[int]]:

List of probes not to return because we already know they are “bad” in some way.

lims_connection: PostgresQueryMixin
error_log: NwbConfigErrorLog

object to store all of the non-fatal irregularities encountered in the data

Returns:
probe_id_to_channels: Dict[int, List[dict]]

A dict mapping probe_id to a list of dicts, each of which represents the specifications of a channel that needs to be written to the input.json.

allensdk.brain_observatory.vbn_2022.input_json_writer.utils.eye_tracking_geometry_from_equipment_id(equipment_id: int, date_of_acquisition: Timestamp, lims_connection: PostgresQueryMixin) dict[source]

Return eye_tracking_rig_geometry given a specified equipment_id and date_of_acquisition

Parameters:
equipment_id: int
date_of_acqisition: pd.Timestamp
lims_connection: PostgresQueryMixin
Returns:
eye_geometry: dict

The eye_tracking_geometry dict to be written to the input.json

This dict conforms to the eye_traking_rig_geometry schema specified in the NWB writer schema (except that it will not list ‘equipment’; that must be added later)

Notes

They eye tracking geometry that is specified is the latest (as determined by LIMS’ active_date column) that occured before date_of_acquisition.

allensdk.brain_observatory.vbn_2022.input_json_writer.utils.probe_input_from_ecephys_session_id(ecephys_session_id: int, probe_ids_to_skip: List[int] | None, lims_connection: PostgresQueryMixin, error_log: NwbConfigErrorLog) List[dict][source]

Get the list of probe specifications, excluding the lists of channels and units, for a given ecephys_session_id

Parameters:
ecephys_session_id: int
probe_ids_to_skip: Optional[List[int]]:

List of probes not to return because we already know they are “bad” in some way.

lims_connection: PostgresQueryMixin
error_log: NwbConfigErrorLog

object to store all of the non-fatal irregularities encountered in the data

Returns:
probe_list: List[dict]

Each dict represents the specifications of a probe that needs to be written to the input.json.

These dicts will not include the channels or units data. Those are added at a later step in processing.

allensdk.brain_observatory.vbn_2022.input_json_writer.utils.session_input_from_ecephys_session_id_list(ecephys_session_id_list: List[int], lims_connection: PostgresQueryMixin, error_log: NwbConfigErrorLog) List[dict][source]

Return a list of dicts, each dict representing the configuration data necessary for writing an NWB file for a session, excluding the lists of probes, channels, and units associated with that session.

Parameters:
ecephys_session_id_list: List[int]

List of ecephys_session_ids for which we are generating the configurations

lims_connection: PostgresQueryMixin
error_log: NwbConfigErrorLog

An object for keeping track of all of the non-fatal irregularities encountered in the data.

Returns:
result: List[dict]

Each dict represents a single session’s configuration

allensdk.brain_observatory.vbn_2022.input_json_writer.utils.unit_input_from_ecephys_session_id(ecephys_session_id: int, probe_ids_to_skip: List[int] | None, lims_connection: PostgresQueryMixin, error_log: NwbConfigErrorLog) Dict[int, list][source]

Get a dict mapping probe_id to the list of unit specifications for a given ecephys_session_id

Parameters:
ecephys_session_id: int
probe_ids_to_skip: Optional[List[int]]:

List of probes not to return because we already know they are “bad” in some way.

lims_connection: PostgresQueryMixin
error_log: NwbConfigErrorLog

object to store all of the non-fatal irregularities encountered in the data

Returns:
probe_id_to_units: Dict[int, List[dict]]

A dict mapping probe_id to a list of dicts, each of which represents the specifications of a unit that needs to be written to the input.json.

allensdk.brain_observatory.vbn_2022.input_json_writer.utils.vbn_nwb_config_from_ecephys_session_id_list(ecephys_session_id_list: List[int], probes_to_skip: List[dict] | None) dict[source]

Return a list of dicts. Each dict the specification for an NWB writer job, suitable for serialization with json.dumps

Parameters:
ecephys_session_id_list: List[int]

The ecephys_session_ids for which you want to create NWB writer specifications

probes_to_skip: List[dict]

A list of dicts, each specifying a probe to ignore when generating the NWB writer specifications. Each dict should look like

{

“session”: 12345 # an ecephys_session_id “probe”: “probeB” # the probe’s name

}

Returns:
A dict
{
“specfications”: the list of dicts representing

the NWB writer specifications

“log”: a string with a summary of all non-fatal

irregularities encountered in the data

}