-
Notifications
You must be signed in to change notification settings - Fork 2
/
InterSpikeInterval.py
55 lines (47 loc) · 2.61 KB
/
InterSpikeInterval.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
import libraries
"""
from pandas import array
import Utility_working as Utility #custom-made utility file, contains lengthy functions
from gettext import install
import numpy as np
import matplotlib.pyplot as plt
import csv
import plotly.express as px
from scipy import signal
import sys
import matplotlib.pyplot as plt
from constant import *
#TODO: Allow python to generate OUtputdata and Figure folders
##if want to customize some varibles, can enter them in terminal (see Unit Test.txt for example)
try:
planeNumber = sys.argv[1]
stimStart = int(sys.argv[2])
stimEnd = int(sys.argv[3])
print("Starting InterspikeInterval with variables from terminal input: planeNumber:",planeNumber,"stimStart:",stimStart,"stimEnd:",stimEnd)
splPrefix = expNumber + "_" + planeNumber + "_"
prefix = expNumber + "_" + planeNumber+ " _frm" + str(stimStart) + "-"+ str(stimEnd)+ "_"
except:
print("Starting InterSpikeInterval with variables in constant.py")
# if have a csv. file with ROIs to remove, it will be included in plotting
try:
AllROIsToRemove = np.loadtxt(pathToData +"BadROIs.csv",delimiter=',',dtype=str)
except:
AllROIsToRemove = np.zeros((3, 6))
print("plotting all ROIs")
#import smoothed data
data = np.loadtxt(pathToOutputData + splPrefix +"Smoothed.csv",delimiter=',',dtype=str)
AllThresholds = np.loadtxt(pathToOutputData + prefix +"AllThresholds.csv",delimiter=',',dtype=str)
ROIsToRemove=Utility.getROIsToRemove(debug, AllROIsToRemove, plane = planeNumber)
ROIdata = Utility.extractData(debug, data, ROIs, ROIsToRemove, stimStart = stimStart, stimEnd = stimEnd)
Starts,Ends = Utility.extractEvent(debug, ROIdata, threshold, baselineStart,baselineEnd)
eventNumber = Utility.eventCounter(debug, Starts)
ISI = Utility.ISI(debug, ROIdata, Starts)
eventAmp = Utility.getEventAmp(debug, ROIdata, Starts, Ends)
np.savetxt(pathToOutputData + prefix + "Starts.csv", Starts, delimiter=',', comments='', fmt='%s')
np.savetxt(pathToOutputData + prefix + "Ends.csv", Ends, delimiter=',', comments='', fmt='%s')
np.savetxt(pathToOutputData + expNumber + "_" + planeNumber + "_" + "AllThresholds.csv", AllThresholds, delimiter=',', comments='', fmt='%s')
znp.savetxt(pathToOutputData + prefix + "EventNumber.csv", eventNumber, delimiter=',', comments='', fmt='%s')
np.savetxt(pathToOutputData + prefix + "ROINames.csv", ROIdata[0,...], delimiter=',', comments='', fmt='%s')
np.savetxt(pathToOutputData + prefix + "ISI.csv", ISI, delimiter=',', comments='', fmt='%s')
np.savetxt(pathToOutputData + prefix + "EventAmp.csv", eventAmp, delimiter=',', comments='', fmt='%s')