Skip to main content

The NWB extension for storing ViRMEN experimental metadata for the Pinto lab.

Project description

ndx-pinto-metadata

The NWB extension for storing ViRMEN experimental metadata for the Pinto lab.

Installation

pip install ndx_pinto_metadata

Usage

from uuid import uuid4
from datetime import datetime
from dateutil.tz import tzlocal
import numpy as np

from pynwb import NWBFile, NWBHDF5IO
from hdmf.common.table import DynamicTable

from ndx_pinto_metadata import LabMetaDataExtension, MazeExtension

# Create NWBFile
nwbfile = NWBFile(
        session_description="session_description",
        identifier=str(uuid4()),
        session_start_time=datetime(1970, 1, 1, tzinfo=tzlocal()),
    )


# Add MazeExtension
maze_extension = MazeExtension(name="mazes", description="Holds information about the mazes for this task.")
# Add row for each maze
maze_extension.add_row(
    antiFraction=0,
    cueDensityPerM=3,
    cueDuration=np.nan,
    cueProbability=np.inf,
    cueVisibleAt=10,
    hideHintUntil=-15,
    lContext=10,
    lCue=45,
    lMemory=10,
    lStart=5,
    maxTrialDuration=180,
    turnHint=1,
    numTrials=80,
    numTrialsPerMin=2,
    criteriaNTrials=100,
    numSessions=1,
    performance=np.inf,
    maxBias=0.2,
    easyBlock=np.nan,
    easyBlockNTrials=10,
    numBlockTrials=40,
    blockPerform=0.55,
    geoDistP=np.nan,
    geoDistPEasy=np.nan,
)

# Create table for storing stimulus protocol parameters
stimulus_protocol = DynamicTable(name="stimulus_protocol", description="Holds information about the stimulus protocol.")

protocol_dict = dict(
    stimulus_code="TowersTaskSwitchStimulusTrain",
    numMazesInProtocol=11,
    trialDraw="EradeCapped",
    stimDraw="LeftOneOnly",
    cueMinSeparation=12,
    totalRepeatProbability=0.05,
    numRepeatTrials=2,
    visualcolor=np.array([0, 0, 1]),
    memorycolor=np.array([0.5, 0.5, 0.]),
    princetonImplementation=1, 
)
for protocol_name in protocol_dict:
    stimulus_protocol.add_column(
        name=protocol_name,
         description="stimulus protocol parameter.",
    )
stimulus_protocol.add_row(**protocol_dict)

# Create LabMetaData
lab_meta_data = LabMetaDataExtension(
    name="LabMetaData",
    experiment_name="TowersTaskSwitchEasy",
    experiment_code="TowersTaskSwitchEasy",
    session_index=49,
    total_reward=0.925,
    surface_quality=74.22,
    rig="VR_Widefield",
    num_trials=242,
    num_iterations=430233,
    session_duration=3838.5730088,
    advance=0,
    mazes=maze_extension,
    stimulus_protocol=stimulus_protocol,
)

# Add to NWBFile
nwbfile.add_lab_meta_data(lab_meta_data=lab_meta_data)

# Write LabMetaData to NWB file
nwbfile_path = "virmen_metadata.nwb"
with NWBHDF5IO(nwbfile_path, mode="w") as io:
    io.write(nwbfile)
            
# Check LabMetaData was added to the NWB file
with NWBHDF5IO(nwbfile_path, mode="r", load_namespaces=True) as io:
    read_nwbfile = io.read()
    read_nwbfile_lab_metadata = read_nwbfile.lab_meta_data["LabMetaData"]

This extension was created using ndx-template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndx-pinto-metadata-0.1.2.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

ndx_pinto_metadata-0.1.2-py2.py3-none-any.whl (5.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ndx-pinto-metadata-0.1.2.tar.gz.

File metadata

  • Download URL: ndx-pinto-metadata-0.1.2.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for ndx-pinto-metadata-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9df7aacc0f53ef3659eba897b26d90ac341fb52b643bd66ce95eed13e4cbe14b
MD5 8849a2a6dd12b40411e0eed5032b5027
BLAKE2b-256 77d2ae04d92271a1faaaa21010c0268247a0e369f6f8019550013967599e60ab

See more details on using hashes here.

File details

Details for the file ndx_pinto_metadata-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ndx_pinto_metadata-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 10a79ccf402b18decc030cb3d1c77c48adb78f2c5697030ee4aa05d526f9b867
MD5 1545bcf83067bf8934557f6dec35be3a
BLAKE2b-256 f05c9cc5b82958da37f51faf966a97936f31e64931bed3b92d4ccc61bdb3b3dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page