nwb

Sketch of the problem:

digraph { subgraph cluster_subject { label = "Subject" subject_schema biography history_table hash_table trial_data extension_schema subject_object } subject_schema -> biography subject_schema -> history_table subject_schema -> hash_table subject_schema -> trial_data subject_schema -> extension_schema subject_object -> subject_schema subgraph cluster_task { label = "Task" task_schema task_timestamps[label="timestamps"] task_trial[label="TrialData"] task_continuous[label="ContinuousData"] } task_schema -> task_trial task_schema -> task_continuous task_schema -> task_timestamps subject_object -> task_schema subgraph cluster_interfaces { label = "Interfaces" generic_hdf5 subgraph cluster_nwbconvert { nwbconverter nwbfile nwbcontainer NWBHDFIO nwbconverter -> nwbfile nwbfile -> nwbcontainer nwbcontainer -> NWBHDFIO } } generic_hdf5 -> subject_file biography -> generic_hdf5 history_table -> generic_hdf5 hash_table -> generic_hdf5 trial_data -> generic_hdf5 extension_schema -> generic_hdf5 task_timestamps -> generic_hdf5 task_trial -> generic_hdf5 task_continuous -> generic_hdf5 subgraph cluster_nwb { label = "NWB" nwb_schema nwb_container nwb_subject[label="file.Subject"] nwb_epoch[label=".BehavioralEpochs"] nwb_events[label="BehavioralEvents"] nwb_create_timeseries[label="create_timeseries"] nwb_create_intervals[label="create_interval_series"] } subgraph cluster_output { subject_file[shape=folder] nwb_file[shape=folder] } NWBHDFIO -> nwb_file nwb_container -> nwb_subject nwb_container -> nwb_epoch nwb_container -> nwb_events nwb_events -> nwb_create_timeseries nwb_epoch -> nwb_create_intervals nwb_create_timeseries -> nwbcontainer nwb_create_intervals -> nwbcontainer biography -> nwbfile task_trial -> nwb_create_timeseries [label="For each"] task_timestamps -> nwb_create_timeseries task_continuous -> nwb_create_intervals }

Functions:

make_biography(bio)

Make an NWB subject object from a biography

Classes:

NWB_Interface

make_biography(bio: autopilot.data.models.biography.Biography) pynwb.file.Subject[source]

Make an NWB subject object from a biography

Todo

make this more flexible based on a mapping

pydantic model NWB_Interface[source]

Bases: autopilot.root.Autopilot_Type

Show JSON schema
{
   "title": "NWB_Interface",
   "description": "Root autopilot model for types",
   "type": "object",
   "properties": {
      "biography": {
         "$ref": "#/definitions/Biography"
      }
   },
   "required": [
      "biography"
   ],
   "definitions": {
      "Breeding": {
         "title": "Breeding",
         "description": "Information about the breeding conditions of the subject",
         "type": "object",
         "properties": {
            "parents": {
               "title": "Parents",
               "description": "The IDs of the parents of this subject, if any",
               "type": "array",
               "items": {
                  "type": "string"
               }
            },
            "litter": {
               "title": "Litter",
               "description": "The identifying number or tag of the litter this subject was born in",
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         },
         "required": [
            "parents",
            "litter"
         ]
      },
      "Enclosure": {
         "title": "Enclosure",
         "description": "Where does the subject live?",
         "type": "object",
         "properties": {
            "box": {
               "title": "Box",
               "description": "The number or name of the box this subject lives in, if any",
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            },
            "building": {
               "title": "Building",
               "description": "The name of the building that the subject is housed in",
               "type": "string"
            },
            "room": {
               "title": "Room",
               "description": "The room number that the animal is housed in",
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         }
      },
      "Baselines": {
         "title": "Baselines",
         "description": "Baseline health measurements for animal care regulation. In the future this\nwill be integrated with a TrialManager class to titrate trials to ensure experimental\nsubjects remain healthy.",
         "type": "object",
         "properties": {
            "mass": {
               "title": "Mass",
               "description": "Mass (grams) of the animal before any experimental manipulation",
               "type": "number"
            },
            "minimum_pct": {
               "title": "Minimum Pct",
               "description": "The proportion (0-1) of the baseline mass that the animal is not allowed to fall under",
               "type": "number"
            }
         }
      },
      "Gene": {
         "title": "Gene",
         "description": "An individual (trans)gene that an animal may have.\n\nI am not a geneticist, lmk what this should look like",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "description": "The name of this gene",
               "type": "string"
            },
            "zygosity": {
               "title": "Zygosity",
               "description": "One of typing.Literal['heterozygous', 'homozygous']",
               "enum": [
                  "heterozygous",
                  "homozygous"
               ],
               "type": "string"
            }
         },
         "required": [
            "name"
         ]
      },
      "Genotype": {
         "title": "Genotype",
         "description": "Genotyping information, information about a subject's background and (potentially multiple) :class:`.Gene` s of interest\n\n.. todo::\n\n    Call Jax's API to get a list of available strain names",
         "type": "object",
         "properties": {
            "strain": {
               "title": "Strain",
               "description": "The strain or background line of this subject, if any",
               "type": "string"
            },
            "genes": {
               "title": "Genes",
               "description": "A list of any transgenes that this animal has",
               "type": "array",
               "items": {
                  "$ref": "#/definitions/Gene"
               }
            }
         }
      },
      "Biography": {
         "title": "Biography",
         "description": "The combined biographical, health, genetic, and other details that define an experimental subject.\n\nThis is stored within the ``/info`` node in a typical :class:`.Subject` file as\nmetadata attributes, and accessible from :attr:`.Subject.info`\n\n**Development Goals**\n\n- Interface with the NWB biographical information schema.",
         "type": "object",
         "properties": {
            "id": {
               "title": "Id",
               "description": "The indentifying string, name, subject_id, etc. for this subject. This value is also used to name the related Subject file, like {id}.h5, so these are typically expected to be unique. If None is provided, a uuid.uuid4() will be generated (which will be ugly so you probably want to give an id).",
               "type": "string"
            },
            "start_date": {
               "title": "Start Date",
               "description": "The date that this subject file was created. Not that this is not necessarily the date that the subject began training, which is more reliably determined from the timestamps within the data. If none is provided, generated from current time.",
               "type": "string",
               "format": "date-time"
            },
            "dob": {
               "title": "Dob",
               "description": "The subject's date of birth. A datetime is allowed, but hours and minutes are typically not reliable. A time of midnight formally indicates that the hour and minute is not precise.",
               "type": "string",
               "format": "date-time"
            },
            "sex": {
               "title": "Sex",
               "description": "Sex of the subject, one of typing.Literal['F', 'M', 'U', 'O']. See :data:`.SEX`",
               "default": "U",
               "enum": [
                  "F",
                  "M",
                  "U",
                  "O"
               ],
               "type": "string"
            },
            "description": {
               "title": "Description",
               "description": "Some lengthier description of the subject, idk go hogwild.",
               "type": "string"
            },
            "tags": {
               "title": "Tags",
               "description": "Any additional key/value tags that apply to this subject. Idiosyncratic metadata can be stored here, but caution should be taken to not overload this field and instead extend the Biography class because these values will not be included in any resulting schema.",
               "type": "object"
            },
            "species": {
               "title": "Species",
               "description": "Species of subject, no recommendation common vs. latin names, but will be integrated with linked data schemas in the future",
               "type": "string"
            },
            "breeding": {
               "$ref": "#/definitions/Breeding"
            },
            "enclosure": {
               "$ref": "#/definitions/Enclosure"
            },
            "baselines": {
               "$ref": "#/definitions/Baselines"
            },
            "genotype": {
               "$ref": "#/definitions/Genotype"
            }
         }
      }
   }
}

Fields
field biography: autopilot.data.models.biography.Biography [Required]
make(sub: Subject, out_dir: pathlib.Path) pynwb.file.NWBFile[source]