Tutorial 1 - Getting started with data

none
[1]:
ipython3
import os
from IPython import display
none
[3]:
ipython3
import imagingplus as ip

imported imagingplus successfully
        version: 0.2-beta

This notebook demonstrates a basic workflow of through imaging+, taking raw input files to create a multi-level data object that contains processed and extracted calcium signal traces.

This tutorial is based off an existing 2photon imaging experiment that includes multiple trials of 2photon imaging and All optical experiments.

The ``imaging+`` pipeline starts with creating an ``Experiment`` object that is a bucket that holds any number and types of imaging trials (such as 2photon imaging, all-optical trials, single-frame images) from the same imaging field of view

Creating an experiment - UPDATED Oct 23 2022

The first step towards starting the analysis pipeline and creating the Experiment object is to create a dictionary (ExperimentMetainfo) to collect the metadata fields required for initializing Experiment. In ExperimentMetainfo, we provide initial information about the experiment.

none
[12]:
ipython3
ExperimentMetainfo = {
    'dataPath': '/home/pshah/mnt/qnap/Data/2020-12-19',  #: main dir where the imaging data is contained
    'saveDir': '/mnt/qnap_share/Data/imagingplus-example/',  #: main dir where the experiment object and the trial objects will be saved to
    "expID": 'RL109',  #: given identification name for experiment
    'comment': 'date: 2020-12-19',  #: notes related to experiment
}

# create Experiment

expobj = ip.Experiment(**ExperimentMetainfo)
***********************
CREATING new Experiment: (expID: RL109)
***********************



saving new pkl object at: /mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl --



******************************
NEW Experiment created:

imagingplus Experiment object (last saved: Sun Oct 23 12:50:47 2022), expID: RL109
file path: /mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl

Load Experiment

Once created, the new Experiment gets saved to the disk using python’s pickle protocol at the location specified in the saveDir field while creating the Experiment.

none
[13]:
ipython3
# we can now load the new expobj from disk storage using pickle in ip.import_obj():
expobj = ip.import_obj('/mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl')

|- Loaded imagingplus.Experiment object (expID: RL109)

none
[14]:
ipython3
# saving the Experiment object can be done anytime to disk from `expobj.save()`:
expobj.save()

# to save the Experiment with a custom path, provide a custom .pkl path and use the .save_pkl() method:
expobj.save_pkl(pkl_path='/mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl')

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl --

saving new pkl object at: /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --
none
[15]:
ipython3
# Note that this updates the save path for this object:
print(expobj.pkl_path)
/mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl

Adding trials to an experiment

After creating the initial Experiment, we move onto adding each trial acquisition from the experiment.

We create each ImagingTrial session by creating a Metainfo dictionary that contains meta-information about each trial.

The ImagingTrial is the primary data container and the object that we will interact with most directly througout all steps of the package.

As a rule of thumb, ImagingTrials within one Experiment should be from the same FOV. There’s no strict constraint against a multi-FOV Experiment, but the workflow is not currently directly designed for multi-FOV analysis.

There are two types of built-in ImagingTrials: TwoPhotonImaging and AllOpticalTrial.

We start with two 2-photon imaging trials. We create a dictionary (TwoPhotonImagingMetainfo) to dump into a TwoPhotonImagingTrial.

Two-Photon Imaging Trial

none
[17]:
ipython3
# when we create the imaging trial, we also add modules for parsing simultaneously temporal data (.paq files) and imaging microscope's parameters for this imaging trial
from imagingplus.processing.paq import PaqData
from imagingplus.processing.imagingMetadata import PrairieViewMetadata


# create trial obj for each trial of experiment

trials_list_spont = ['t-005', 't-006']
for idx, trial in enumerate(trials_list_spont):
    date = '2020-12-19'
    prep = expobj.expID

    # define paths to retrieve data from disc
    paqs_loc = f'/home/pshah/mnt/qnap/Data/2020-12-19/{date}_{prep}_{trial[-3:]}.paq'  # path to the .paq files for the selected trials
    dataPath = f'/home/pshah/mnt/qnap/Data/2020-12-19/{date}_{trial}/{date}_{trial}_Cycle00001_Ch3.tif'


    # initialize microscope meta-data for current imaging trial using pre-built module for Bruker-PrairieView xml parser
    imparams = PrairieViewMetadata(pv_xml_dir=os.path.dirname(dataPath), microscope='Bruker 2pPlus')

    # initialize temporal data using pre-built module for .paq parsing
    tmdata = PaqData.paqProcessingTwoPhotonImaging(paq_path=paqs_loc, frame_channel='frame_clock', plot=False)

    # feed in information into `TwoPhotonImaging` to create a TwoPhotonImaging object
    trialobj = ip.TwoPhotonImaging(date=date, trialID= trial, expID= prep, imparams =  imparams, tmdata= tmdata,
                                saveDir=f'/mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/',
                                dataPath= dataPath, expGroup= "awake spont. 2p imaging + LFP")


    # add each Trial to the overall Experiment using the trialobj
    expobj.add_imaging_trial(trialID=trial, trialobj=trialobj)

\- Adding Imaging Acquisition Metadata from Bruker 2pPlus ...

        \- Parsing PV Metadata for Bruker microscope...
         searching for xml path in tiff path directory at: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-005 ...
        n planes: 1
        n frames: 14880
        fps: 29.75971618277715
        frame size (px): 512 y 512
        zoom: 1.0
        pixel size (um): 2.18458479264539 2.18458479264539
        scan centre (V): 0.0 0.0
        loading Paq cellsdata from: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_005.paq
         - loaded 8 channels from .Paq file: ['frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage']

\- ADDING PAQ DATA from /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_005.paq...
        loading Paq cellsdata from: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_005.paq
../_images/Tutorials_Tutorial-1-Overview-of-Workflow_16_1.png
         - loaded 8 channels from .Paq file: ['frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage']
Created new TemporalData of 8 x 10370240 (sampled at 20000

        \- Retrieving two-photon imaging frame times from .paq channel: frame_clock ...

        \- Getting imaging key frames timed cellsdata from 14887 frames ...
                \- Adding sparse tmdata for channel: frame_clock
                \- Adding sparse tmdata for channel: x_galvo_uncaging
                \- Adding sparse tmdata for channel: slm2packio
                \- Adding sparse tmdata for channel: markpoints2packio
                \- Adding sparse tmdata for channel: packio2slm
                \- Adding sparse tmdata for channel: packio2markpoints
                \- Adding sparse tmdata for channel: pycontrol_rsync
                \- Adding sparse tmdata for channel: voltage
        |- Collected sparse data:  (14887, 8) ...
\----- CREATING TwoPhotonImagingTrial for trial: t-005

-----collecting mean raw flu trace from tiff file...
saving new trial object to: /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-005.pkl

         -- data object saved to /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-005.pkl --

         -- data object saved to /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-005.pkl --


\- ADDING trial: t-005 to RL109 experiment
        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --
|- ADDED trial: t-005 to RL109 experiment

\- Adding Imaging Acquisition Metadata from Bruker 2pPlus ...

        \- Parsing PV Metadata for Bruker microscope...
         searching for xml path in tiff path directory at: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-006 ...
        n planes: 1
        n frames: 23173
        fps: 29.75972061098135
        frame size (px): 512 y 512
        zoom: 1.0
        pixel size (um): 2.18458479264539 2.18458479264539
        scan centre (V): 0.0 0.0
        loading Paq cellsdata from: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_006.paq
         - loaded 8 channels from .Paq file: ['frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage']

\- ADDING PAQ DATA from /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_006.paq...
        loading Paq cellsdata from: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_006.paq
../_images/Tutorials_Tutorial-1-Overview-of-Workflow_16_3.png
         - loaded 8 channels from .Paq file: ['frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage']
Created new TemporalData of 8 x 15788192 (sampled at 20000

        \- Retrieving two-photon imaging frame times from .paq channel: frame_clock ...

        \- Getting imaging key frames timed cellsdata from 23181 frames ...
                \- Adding sparse tmdata for channel: frame_clock
                \- Adding sparse tmdata for channel: x_galvo_uncaging
                \- Adding sparse tmdata for channel: slm2packio
                \- Adding sparse tmdata for channel: markpoints2packio
                \- Adding sparse tmdata for channel: packio2slm
                \- Adding sparse tmdata for channel: packio2markpoints
                \- Adding sparse tmdata for channel: pycontrol_rsync
                \- Adding sparse tmdata for channel: voltage
        |- Collected sparse data:  (23181, 8) ...
\----- CREATING TwoPhotonImagingTrial for trial: t-006

-----collecting mean raw flu trace from tiff file...
saving new trial object to: /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-006.pkl

         -- data object saved to /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-006.pkl --

         -- data object saved to /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-006.pkl --


\- ADDING trial: t-006 to RL109 experiment
        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --
|- ADDED trial: t-006 to RL109 experiment
none
[18]:
ipython3
# save the experiment object after adding new trials
expobj.save()
print(expobj)

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --
imagingplus Experiment object (last saved: Sun Oct 23 12:59:35 2022), expID: RL109
file path: /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl

trials in Experiment object:
        t-005: awake spont. 2p imaging + LFP
        t-006: awake spont. 2p imaging + LFP

We can see above now that our Experiment contains two newly added TwoPhotonImagingTrial.

none
[19]:
ipython3
# we can access each trial's information from within the `expobj`
expobj.TrialsInformation
none
[19]:
{'t-005': {'date': '2020-12-19',
  'trialID': 't-005',
  'expID': 'RL109',
  'expGroup': 'awake spont. 2p imaging + LFP',
  'comment': '',
  'paths': {'dataPath': '/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-005/2020-12-19_t-005_Cycle00001_Ch3.tif',
   'pkl_path': '/mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-005.pkl',
   'data_path': '/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-005/2020-12-19_t-005_Cycle00001_Ch3.tif',
   'data_path_dir': '/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-005'}},
 't-006': {'date': '2020-12-19',
  'trialID': 't-006',
  'expID': 'RL109',
  'expGroup': 'awake spont. 2p imaging + LFP',
  'comment': '',
  'paths': {'dataPath': '/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-006/2020-12-19_t-006_Cycle00001_Ch3.tif',
   'pkl_path': '/mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-006.pkl',
   'data_path': '/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-006/2020-12-19_t-006_Cycle00001_Ch3.tif',
   'data_path_dir': '/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-006'}}}
none
[20]:
ipython3
# we can also load each trial directly from the experiment:
trialobj = expobj.load_trial(trialID = 't-005')

|- Loaded 'RL109 t-005 (TwoPhotonImagingTrial experimental object)'t-analysis/2020-12-19_t-005.pkl ...

AllOptical Trial

Next, we will add an AllOpticalTrial to our Experiment.

none
[21]:
ipython3
from imagingplus.processing.paq import PaqData
from imagingplus.processing.imagingMetadata import PrairieViewMetadata


date = '2020-12-19'
prep = expobj.expID

# define paths to retrieve data from disc
paqs_loc = f'/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_013.paq'  # path to the .paq files for the selected trials
dataPath = f'/home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013/2020-12-19_t-013_Cycle00001_Ch3.tif'


initialization_dict = {'naparm_path': f'/home/pshah/mnt/qnap/Data/2020-12-19/photostim/2020-12-19_RL109_ps_014/',
                       'dataPath': dataPath,
                       'saveDir': f'/home/pshah/mnt/qnap/Data/2020-12-19/',
                       'date': '2020-12-19',
                       'trialID': 't-013',
                       'expID': 'RL109',
                       'expGroup': 'all optical trial with LFP',
                       'comment': 'n/a'}

# parses imaging system cellsdata
imparams = PrairieViewMetadata(pv_xml_dir=os.path.dirname(dataPath), microscope='Bruker 2pPlus')

# sets the stim start frames
tmdata = PaqData.paqProcessingAllOptical(paq_path=paqs_loc, frame_channel='frame_clock',
                                         stim_channel='markpoints2packio', plot=False)

\- Adding Imaging Acquisition Metadata from Bruker 2pPlus ...

        \- Parsing PV Metadata for Bruker microscope...
         searching for xml path in tiff path directory at: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013 ...
        n planes: 1
        n frames: 16368
        fps: 29.75972061098135
        frame size (px): 512 y 512
        zoom: 1.0
        pixel size (um): 2.18458479264539 2.18458479264539
        scan centre (V): 0.0 0.0
        loading Paq cellsdata from: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_013.paq
         - loaded 8 channels from .Paq file: ['frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage']

\- ADDING PAQ DATA from /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_013.paq...
        loading Paq cellsdata from: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_RL109_013.paq
../_images/Tutorials_Tutorial-1-Overview-of-Workflow_23_1.png
         - loaded 8 channels from .Paq file: ['frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage']
Created new TemporalData of 8 x 11864768 (sampled at 20000

        \- Retrieving two-photon imaging frame times from .paq channel: frame_clock ...

        \- Getting imaging key frames timed cellsdata from 16376 frames ...
                \- Adding sparse tmdata for channel: frame_clock
                \- Adding sparse tmdata for channel: x_galvo_uncaging
                \- Adding sparse tmdata for channel: slm2packio
                \- Adding sparse tmdata for channel: markpoints2packio
                \- Adding sparse tmdata for channel: packio2slm
                \- Adding sparse tmdata for channel: packio2markpoints
                \- Adding sparse tmdata for channel: pycontrol_rsync
                \- Adding sparse tmdata for channel: voltage
        |- Collected sparse data:  (16376, 8) ...
# of stims found on markpoints2packio: 100
../_images/Tutorials_Tutorial-1-Overview-of-Workflow_23_3.png
none
[22]:
ipython3
# create a sparse version of all temporal data series timealigned to frame times
tmdata.sparse_data = tmdata.get_sparse_data()

        \- Getting imaging key frames timed cellsdata from 16376 frames ...
                \- Adding sparse tmdata for channel: frame_clock
                \- Adding sparse tmdata for channel: x_galvo_uncaging
                \- Adding sparse tmdata for channel: slm2packio
                \- Adding sparse tmdata for channel: markpoints2packio
                \- Adding sparse tmdata for channel: packio2slm
                \- Adding sparse tmdata for channel: packio2markpoints
                \- Adding sparse tmdata for channel: pycontrol_rsync
                \- Adding sparse tmdata for channel: voltage
        |- Collected sparse data:  (16376, 8) ...
none
[23]:
ipython3
# create the trial
aotrial = ip.AllOpticalTrial(imparams=imparams, tmdata=tmdata, **initialization_dict)
\----- CREATING TwoPhotonImagingTrial for trial: t-013

-----collecting mean raw flu trace from tiff file...
saving new trial object to: /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013.pkl

         -- data object saved to /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013.pkl --

         -- data object saved to /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013.pkl --

\----- parsing Naparm xml file...
loading NAPARM_xml_path:
['/home/pshah/mnt/qnap/Data/2020-12-19/photostim/2020-12-19_RL109_ps_014/2020-12-19_RL109_ps_014.xml']
        Numbers of trials: 100
        Number of groups: 4
        Number of shots: 10
        Number of sequence reps: 1
        Inter-point delay: 5
        Spiral Duration (ms): 20

\----- parsing Naparm gpl file...
['/home/pshah/mnt/qnap/Data/2020-12-19/photostim/2020-12-19_RL109_ps_014/2020-12-19_RL109_ps_014.gpl']
loading NAPARM_gpl_path:  /home/pshah/mnt/qnap/Data/2020-12-19/photostim/2020-12-19_RL109_ps_014/2020-12-19_RL109_ps_014.gpl
Single stim dur (ms): 10
Spiral size .gpl file: 0.047535
spiral size (um): 10
Single stim. Duration (ms):  20
Total stim. Duration per trial (ms):  1000

        \----- Loading up target coordinates...
                Number of targets (in SLM group 1):  9
                Number of targets (in SLM group 2):  9
                Number of targets (in SLM group 3):  9
                Number of targets (in SLM group 4):  9
                Number of targets (total): 36
                spiral size: 10.0um
                pix sz x: 2.18458um
                radius (in pixels): 6.55px
                radius of target exclusion zone (in pixels): 8.74px

\----- Finding photostimulation frames in imaging frames ...
# of photostim frames calculated per stim. trial:  31
        |- # of Imaging frames: 16368 frames
        |- # of Photostimulation frames: 0 frames

----------------------------------------------------------------
running trial Processing for all cells
----------------------------------------------------------------
Photostim. processing of fluorescence signal responses cannot be performed without Suite2p cellsdata.

         -- data object saved to /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013.pkl --
\----- CREATED AllOpticalTrial cellsdata object for RL109 t-013
none
[24]:
ipython3
expobj.add_imaging_trial(trialobj=aotrial)


\- ADDING trial: t-013 to RL109 experiment
        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --
|- ADDED trial: t-013 to RL109 experiment
none
[25]:
ipython3
print(expobj)
imagingplus Experiment object (last saved: Sun Oct 23 13:02:29 2022), expID: RL109
file path: /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl

trials in Experiment object:
        t-005: awake spont. 2p imaging + LFP
        t-006: awake spont. 2p imaging + LFP
        t-013: all optical trial with LFP

none
[26]:
ipython3
# save the experiment object after adding new trials
expobj.save()

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --

Adding calcium imaging processing to Experiment

After creating the Experiment and loading each Trial, we can move on to data analysis.

We start with adding Suite2p functionality to our Experiment.

We provide helpful wrapper functions that allow quick access Suite2p functionality directly from the Experiment or the ImagingTrial.

Suite2p results provides both CellAnnotations and ImagingData to each ImagingTrial

none
[27]:
ipython3
# we plan to use all trials from the experiment for Suite2p
expobj.add_suite2p(s2p_trials=['t-005', 't-006', 't-013'],
                  s2pResultsPath="/home/pshah/mnt/qnap/Analysis/2020-12-19/suite2p/alloptical-2p-1x-alltrials/plane0/")
\- Adding suite2p module to experiment. Located under .Suite2p
\----- Adding Suite2p results to .Suite2p module ...
Loading 640 traces labelled as cells
|- Loaded [1] suite2p classified cells from plane 0, recorded for 8533.93 secs total, 256018 frames total
|- ADDED .Suite2p module to Experiment object.

|- Loaded 'RL109 t-005 (TwoPhotonImagingTrial experimental object)'t-analysis/2020-12-19_t-005.pkl ...


        |- current trial key_frames: (0, 14880) out of 256018 total key_frames processed through suite2p
\- added CellAnnotations module. consisting of 15 annotations x 640 cells.
\- added ImagingData module. consisting of (640, 14880) ROIs x Frames.

\----- ADDED .Suite2p module to trial.
         -- data object saved to /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-005.pkl --

|- Loaded 'RL109 t-006 (TwoPhotonImagingTrial experimental object)'t-analysis/2020-12-19_t-006.pkl ...


        |- current trial key_frames: (14880, 38053) out of 256018 total key_frames processed through suite2p
\- added CellAnnotations module. consisting of 15 annotations x 640 cells.
\- added ImagingData module. consisting of (640, 23173) ROIs x Frames.

\----- ADDED .Suite2p module to trial.
         -- data object saved to /mnt/qnap_share/Data/imagingplus-example/imagingplus-test-analysis/2020-12-19_t-006.pkl --

|- Loaded TwoPhotonImagingTrial.alloptical experimental trial object ...


        |- current trial key_frames: (38053, 54421) out of 256018 total key_frames processed through suite2p
\- added CellAnnotations module. consisting of 15 annotations x 640 cells.
\- added ImagingData module. consisting of (640, 16368) ROIs x Frames.

\----- ADDED .Suite2p module to trial.
         -- data object saved to /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013.pkl --
|- Finished adding suite2p module to experiment and trials. Located under .Suite2p

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --
none
[28]:
ipython3
# save the experiment object after adding new trials
expobj.save()

expobj.save_pkl('/mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl')

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_duplicate_analysis.pkl --

saving new pkl object at: /mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl

        |- Experiment analysis object saved to /mnt/qnap_share/Data/imagingplus-example/RL109_analysis.pkl --
none
[29]:
ipython3
# direct access to important Suite2p outputs from ImagingTrial and the Experiment instances
print(expobj.Suite2p)
Suite2p Results (Experiment level) Object, containing trials:
        ['t-005', 't-006', 't-013']
none
[30]:
ipython3
aotrial.Suite2p

Load all-optical trial

none
[31]:
ipython3
aotrial = expobj.load_trial(trialID = 't-013')

|- Loaded TwoPhotonImagingTrial.alloptical experimental trial object ...

Storing Suite2p processed data as an anndata structure

none
[35]:
ipython3
# create annotated data object

# anndata storage submodule
aotrial.data = aotrial.create_anndata(imdata=aotrial.Suite2p,
                                     cells=aotrial.Suite2p,
                                     tmdata=aotrial.tmdata.sparse_data,
                                     imdata_type='suite2p raw - neuropil corrected')

aotrial.save()
WARNING: mismatch of timestamps in tmdata (16376) and frames in imdata (16368) passed to anndata creation.

\----- CREATING annotated cellsdata object using AnnData:
Created AnnData object:
        Annotated Data of n_obs (# ROIs) × n_vars (# Frames) = 640 × 16368

Annotated Data of n_obs × n_vars = 640 × 16368
available attributes:
        .X (primary datamatrix) of .data_label:
                |- suite2p raw - neuropil corrected
        .obs (obs metadata):
                |- 'ypix', 'xpix', 'lam', 'footprint', 'mrs', 'mrs0', 'compact', 'med', 'npix', 'overlap', 'radius', 'aspect_ratio', 'npix_norm', 'skew', 'std'
        .var (vars metadata):
                |- 'frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage'
        .obsm:
                |- 'ypix', 'xpix'

         -- data object saved to /home/pshah/mnt/qnap/Data/2020-12-19/2020-12-19_t-013.pkl --
none
[36]:
ipython3
# all data streams can be accessed directly out of one variable (yes, one variable!!)
print(aotrial.data)
Annotated Data of n_obs × n_vars = 640 × 16368
available attributes:
        .X (primary datamatrix) of .data_label:
                |- suite2p raw - neuropil corrected
        .obs (obs metadata):
                |- 'ypix', 'xpix', 'lam', 'footprint', 'mrs', 'mrs0', 'compact', 'med', 'npix', 'overlap', 'radius', 'aspect_ratio', 'npix_norm', 'skew', 'std'
        .var (vars metadata):
                |- 'frame_clock', 'x_galvo_uncaging', 'slm2packio', 'markpoints2packio', 'packio2slm', 'packio2markpoints', 'pycontrol_rsync', 'voltage'
        .obsm:
                |- 'ypix', 'xpix'
none
[34]:
ipython3
aotrial.tmdata.data
none
[34]:
frame_clock x_galvo_uncaging slm2packio markpoints2packio packio2slm packio2markpoints pycontrol_rsync voltage stim_start_times
0 0.005525 -1.167153 3.338084 0.005854 -0.001710 0.000264 1.320265 0.055181 False
1 0.005854 -1.166824 3.339728 0.007827 0.000264 -0.000065 1.237395 0.053866 False
2 0.005854 -1.165509 3.336768 0.007169 -0.000394 0.000592 1.158142 0.056168 False
3 0.005525 -1.166495 3.334138 0.006183 -0.000065 0.000264 1.084809 0.054524 False
4 0.005854 -1.166824 3.331178 0.007169 0.002565 0.000592 1.018710 0.055510 False
... ... ... ... ... ... ... ... ... ...
11864763 0.006512 -1.165837 3.331836 0.008156 0.001579 0.000921 0.022296 3.461073 False
11864764 0.007498 -1.165180 3.333151 0.006512 0.000592 0.000592 0.018679 3.461402 False
11864765 0.006512 -1.164851 3.335782 0.007827 -0.001052 0.000264 0.018350 3.461731 False
11864766 0.008485 -1.164851 3.341701 0.008156 -0.000065 0.000592 0.020323 3.461073 False
11864767 0.006512 -1.164851 3.344990 0.009142 -0.001052 0.000592 0.019008 3.461402 False

11864768 rows × 9 columns

none
[ ]:
ipython3