Skip to content

Alex-de-Lecea/NAPE_imaging_postprocess

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAPE_imaging_postprocess

Package for functional imaging postprocessing analysis. The primary goal is to take time-series data from simultaneously-recorded cells/ROIs and event (behavior and/or manipulations) timing to gain an understanding of how individual and groups of cells relate to such external manipulations.

Anaconda Environment Installation:

  1. After cloning/downloading the repository, open Anaconda Prompt (the following processes can also be performed in Anaconda Navigator)
  2. Locate the full path to the repository and in the prompt, execute cd *path_to_repo*. Example: cd C:\Users\napeadmin\Documents\GitHub\NAPE_imaging_postprocess
  3. Execute conda env create -n napeca_post -f napeca_post.yml. This should create a new anaconda environment called napeca_post that contains the relevant packages for running the post-processing scripts
  4. Execute conda activate napeca_post to enable the newly created environment

Modules:

  • whole_session_event_ticks: Plot activity traces for each ROI across whole session (Optional - primarily for sanity check/prelim viz purposes)
  • plot_activity_contours: Work-in-progress; Plots the cell ROI contours onto the projection image. ROI contours are color-coded based on the amplitude of the mean event-triggered response for each condition. Bar plots at the end illustrate condition preference.
  • event_rel_analysis: Primary event-related analysis script: Plots trial-, roi-, time-resolved event-triggered responses for each and across all ROIs. Also plots average responses in each dimension.
  • Example of spectral clustering: Kmeans/Spectral clustering of ROIs based on event-related responses. REQUIRES the above script to be run (event_rel_analysis)

Suite2p-related Modules:

  • s2p_conversion: Processes and converts suite2p output signals, and saves a dataframe or np array of neuropil-corrected roi activity traces as both a csv and npy file. Either output files can be used for downstream analyses (eg. event_rel_analysis, s2p_plot_rois_and_activity)
  • s2p_plot_rois_and_activity: Plot the cell ROI contours from Suite2p onto the session's projection image, and generates lineplots for each ROI's whole-session activity trace

SIMA-related Modules:

  • sima_plot_ROI_contours: Plot the cell ROI contours from SIMA/NAPECA onto the session's projection image, and generates lineplots for each ROI's whole-session activity trace

Example workflows:

Ran NAPECA pipeline for preprocessing:

  1. Preprocess (motion correct, signal extract, neuropil correct) using NAPECA pipeline
  2. If you want to plot ROI contours and associated whole-session activity, run sima_plot_ROI_contours.ipynb
  3. The user should create an event CSV that contains trial event types and their timing (see example below) or if using Bruker data, generate a pickle file using the Bruker prepreprocessing code in NAPECA preprocessing repository (https://github.com/zhounapeuw/NAPE_imaging_analysis/blob/master/napeca/prepreprocess/bruker_data_process.ipynb)
  4. Run any of the main modules (with the fnames pointing to the NAPECA output; eg. VJ_OFCVTA_7_260_D6_neuropil_corrected_signals_15_50_beta_0.8.npy, and framenumberforevents_VJ_OFCVTA_7_260_D6_trained.pkl. Data from NAPECA are immediately compatible with the main postprocessing modules.

Ran Suite2p for preprocessing:

  1. Run s2p_conversion.ipynb to convert s2p output signals into either a csv or npy
  2. If you want to plot ROI contours and associated whole-session activity, run s2p_plot_rois_and_activity.ipynb
  3. The user should create an event CSV that contains trial event types and their timing (see example below)
  4. Run any of the main modules

How should you format your activity/signal data:

  1. If you are using Inscopix: reference the csv containing ROI signals
  2. If you preprocessed your 2p data using Suite2p: Run the s2p_conversion.ipynb code first before moving to the main scripts
  3. If you are using the NAPECA Preprocessing pipeline: Run the main scripts while referencing the extracted signals or neuropil-corrected signals (npy files)
  4. All other data sources: The most straightforward approach is to create CSV files with the dimensions illustrated in the picture below

whole_session_plot

How should you format your behavioral data (if not using Bruker prepreprocess script for behavioral event extraction):

  1. The code is looking primarily for a dictionary where keys are the trial conditon names and the values are lists containing the event occurrences in samples/frames
  2. The most straightforward, general approach is to create a CSV file containing event data in the tidy format illustrated in the picture below

whole_session_plot

Example Figure Outputs:

ROI contours plotted on projection image (s2p_plot_rois_and_activity):

roi_contour_map

Activity traces for each ROI, colors corresponding to ROIs above (s2p_plot_rois_and_activity):

roi_ts

Activity traces for each ROI across whole session, with event occurrences plotted (whole_session_event_ticks):

whole_session_event

Event-related responses averaged and across trials (event_rel_analysis):

roi_1_activity

Event-related response heatmaps across ROIs (event_rel_analysis):

trial_avg_heatmap

Event-related responses averaged across trials and ROIs (event_rel_analysis):

roi_trial_avg_trace

Spectral clustering of ROIs based on event-related response profiles (Example of spectral clustering; to be renamed):

cluster_heatmap

ROI-averaged activity traces after clustering (Example of spectral clustering):

cluster_roiAvg_traces

Authors

  • Zhe Charles Zhou - Initial and ongoing work; Director - Zhou NAPE UW
  • Lauren Ran Liao - Machine Learning Development - Lauren Liao

About

Package for functional imaging postprocessing analysis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 94.9%
  • Python 5.1%