-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinderSpiker_ActionPotentials.m
88 lines (88 loc) · 2.92 KB
/
FinderSpiker_ActionPotentials.m
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
%% FinderSpiker.APs
% Action Potentiall Features:
% INPUT
% Experiment Data: ABF, CSV or xlx file
% OUTPUT
% .CSV Table of Features
% .mat File for posterioir anlaysis
%% Setup
clc; clear; close all;
Import_FinderSpikerAPs;
%% LOAD DATA
% Select kind of file:
% ABF/EXCEL/CSV
choiceFile=0;
fprintf('>>Select type of data file of the experiment:\n');
fprintf('\n 1)ABF\n')
fprintf(' Files acquired with pCLAMP versions <10\n')
fprintf(' Read units from file\n')
fprintf('\n 2)CSV\n')
fprintf(' ImPatch aquisition\n')
fprintf(' Separated Voltage and Current Files\n')
fprintf('\n 3)XLSX:\n')
fprintf(' Time in ms\n')
fprintf(' Voltage in mV\n')
fprintf(' Current in pA\n')
while choiceFile==0
choiceFile = menu('Choose a Data File Type','ABF (pCAMP v<10)','CSV (ImPatch Files)','XLSX (copy-paste)');
end
switch choiceFile
case 1
fprintf('>>ABF file for versions <2\n')
[Xcurrent,Xvoltage,fs,FileName]=load_VI_abf;
EndStr=find(FileName=='.');
FileName=FileName(1:EndStr-1);
case 2
fprintf('>>CSV files: separated current and voltage files\n')
[Xvoltage,Xcurrent,fs,FileName]=Load_Impatch_Files;
case 3
fprintf('>>XLSX file for copy-paste from pCLAMP to excel file\n')
[Xvoltage,Xcurrent,fs,FileName]=Load_VI_excel;
EndStr=find(FileName=='.');
FileName=FileName(1:EndStr-1);
end
% Check Experiment ID
ExpIDDef{1}=FileName;
% Confirm ID of the Experiment
ExpInput= inputdlg('Experiment ID: ','Confirm unique ID:/Press Canel to use default', [1 75],ExpIDDef);
if ~isempty(ExpInput)
Experiment=ExpInput{1};
Experiment(Experiment==' ')='_'; % REPLACE SpaceS with '_'
end
fprintf('>>Experiment ID: %s\n',Experiment);
%% Get Firing Rates
[FR,APs,PulseP]=getfiringrate(Xcurrent,Xvoltage,fs);
fprintf('>>Completed Automatic Detection\n')
%% Save mat File
fprintf('>>Saving data: ')
FolderNamePD='Processed Data\';
% Direcotry to Save: Up from this one (pwd)
FileDirSave=pwd;
slashes=find(FileDirSave=='\');
FileDirSave=FileDirSave(1:slashes(end));
if ~isdir([FileDirSave,FolderNamePD])
fprintf('Folder [%s] created,',FolderNamePD)
mkdir([FileDirSave,FolderNamePD]);
end
save([FileDirSave,FolderNamePD,Experiment,'.mat'],'Experiment','Xcurrent',...
'Xvoltage','fs','FR','APs','PulseP');
fprintf('done.\n')
%% Save Table
fprintf('>>Saving Table: ')
FolderTable='Firing Tables\';
if ~isdir([FileDirSave,FolderTable])
fprintf('Directory [%s] created',FolderTable)
mkdir([FileDirSave,FolderTable]);
end
writetable(FR,[FileDirSave,FolderTable,Experiment,'_FR.csv'],...
'Delimiter',',','QuoteStrings',true);
fprintf('done.\n')
disp(FR);
fprintf('>>Table saved @: \n%s\n%s\n',...
[FileDirSave,FolderTable],[Experiment,'_FR.csv'])
fprintf('>>APs Intel @: \n%s\n%s\n',...
[FileDirSave,FolderNamePD],[Experiment,'.mat'])
fprintf('>>For Visual Inspection Run: \n>>Action_Potentials_Check\n')
%% Check Recordings:
close all;
Action_Potentials_Check;