Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Fiber Photometry analysis
#1
Hi all,
I have a problem extracting events from a fiber photometry file using python.
I have 2 different files: the first one contains raw data (col 1: time milliseconds, col 2: GCaMP raw data) and the second file contains events of opto stimulation (col 1: time milliseconds and col 2 a series of 0 and 1 where length of 1 corresponding to the opto stimulation and length of zeros corresponding to no-stim). I'm able to extract the raw data, correct for bleaching and plot the Calcium signaling from the first file. However, I'm having troubles extracting the data around the opto stimulation from the second file and plot the signal around (+/- 5 seconds) the stimulation event.
here is the code I'm using for data extraction and plot:

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import medfilt
from scipy.optimize import curve_fit
import seaborn as sns
from scipy.signal import medfilt, butter, filtfilt


data = pd.read_csv('GG1_fip_20Hz2019-05-11T11_38_00.csv', header=None, delimiter=',')
stim_data = pd.read_csv('GG1_20Hz_stim2019-05-11T11_37_58.csv', header=None, delimiter=',')

# extract values from FIP file
GCaMP = np.array(data[2])
row_time_fip = np.array(data[0])
time_fip = np.array(data[0] / 1000)  # millisecond
normalized_time_sec = np.array(time_fip - min(time_fip))
normalized_time_min = np.array(normalized_time_sec / 60)

# extract values from stim file
stim_all = np.array(stim_data)
stim_onset = np.array(stim_data[1])
time_event = np.array(stim_data[0]/1000)
time_event_raw = np.array(stim_data[0])
normalized_time_event_sec = np.array(time_event - min(time_event))
normalized_time_event_min = np.array(normalized_time_sec / 60)


# denoise GCaMP signal (remove artifacts --> kernel should be odd number
GCaMP_denoised = (medfilt(GCaMP, kernel_size=51))


# method 1 bleaching correction = polyfit
coefs_GCaMP = np.polyfit(time_fip, GCaMP_denoised, deg=4)
GCaMP_polyfit = np.polyval(coefs_GCaMP, time_fip)

plt.subplot(2,1,1)
plt.plot(normalized_time_min, GCaMP_denoised, 'g', label='GCaMP')
plt.plot(normalized_time_min, GCaMP_polyfit,'k', linewidth=1.5)
plt.subplot(2,1,2)

GCaMP_ps = GCaMP_denoised - GCaMP_polyfit
plt.plot(normalized_time_min, GCaMP_ps, 'g', label='GCaMP')

plt.subplots_adjust(top=0.95, bottom=0.1, left=0.12, right=0.95, hspace=0.6, wspace=0.35)
plt.xlabel('Time (min)')

# method 2 bleaching correction = highpass slow frequency
b,a = butter(2, 0.001, btype='high')
GCaMP_highpass = filtfilt(b,a, GCaMP_denoised, padtype='even')
plt.plot(normalized_time_min, GCaMP_highpass)
plt.show()
raw data:
https://drive.google.com/open?id=1oIkV1H...xnp2QM9OMb
https://drive.google.com/open?id=1UkxSau...WL23wHepHt
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Plot/Image analysis %of colored area(grid) TiBotLCPP 0 152 Jul-09-2019, 02:33 PM
Last Post: TiBotLCPP
  Market Basket Analysis: Finding Association Rules kylenater 1 255 Jun-21-2019, 03:53 AM
Last Post: scidam
  Statistical analysis of two dataframes zhl 1 462 Jun-11-2019, 07:26 PM
Last Post: Ecniv
  Sentiment Analysis Classifier lode 0 395 Feb-04-2019, 05:00 AM
Last Post: lode
  PyCM 1.8 released: Machine learning library for confusion matrix statistical analysis sepandhaghighi 0 345 Jan-05-2019, 12:36 PM
Last Post: sepandhaghighi
  Load .abf file and for analysis with Pandas finalcode 0 444 Nov-10-2018, 09:51 AM
Last Post: finalcode
  Image Analysis for Measurement of Total leaf Area teamaqua 1 1,136 Aug-27-2017, 12:05 PM
Last Post: Larz60+
  Excel analysis SamB 3 1,839 Jul-04-2017, 09:52 PM
Last Post: zivoni

Forum Jump:


Users browsing this thread: 1 Guest(s)