-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiment_2024_07_22b.m
60 lines (50 loc) · 2.22 KB
/
experiment_2024_07_22b.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
%%EXPERIMENT_2024_07_22b Runs experiment (2024-07-22b: Pilot-8).
SUBJECT_NAME = "Pilot_SCS_N_CEJ_08"; % Name of the subject
START_SWEEP = 0; % Modify this if you have to reset in the middle.
START_BLOCK = 0; % Modify this if you have to reset in the middle.
RAW_DATA_ROOT = parameters('raw_data_folder_root'); % Should be correct on NML Rodent lab computer
AMPLIFIER_CHANNELS = 0:15;
AMPLIFIER_PORT = 'b';
IPV4_ADDRESS_AM4100 = "10.0.0.80"; % Network Address of AM4100 unit
IPV4_ADDRESS_INTAN = "127.0.0.1"; % Device running Intan acquisition
IPV4_ADDRESS_TMSI = "127.0.0.1"; % Device running TMSi acquisition
MAP_NAME_LOCAL = sprintf('%s_Channel_Map.txt',SUBJECT_NAME);
DATA_TANK_ROOT = fullfile(RAW_DATA_ROOT,SUBJECT_NAME);
if exist(DATA_TANK_ROOT,'dir')==0
mkdir(DATA_TANK_ROOT);
end
MAP_NAME_REMOTE = fullfile(RAW_DATA_ROOT, MAP_NAME_LOCAL);
if exist(MAP_NAME_LOCAL,'file')==0
copyfile('Default_Mouse_EMG_Channel_Map.txt', MAP_NAME_LOCAL);
copyfile('Default_Mouse_EMG_Channel_Map.txt', MAP_NAME_REMOTE);
else
copyfile(MAP_NAME_LOCAL, MAP_NAME_REMOTE);
end
fprintf(1,'Put Channel Map in <b>%s</b>\n',MAP_NAME_REMOTE);
ABOUT_NAME_REMOTE = fullfile(DATA_TANK_ROOT, "about.yaml");
if exist(ABOUT_NAME_REMOTE,'file')==0
copyfile(fullfile(pwd,'about_template.yaml'),ABOUT_NAME_REMOTE);
fprintf(1,'Put template about.yaml in <b>%s</b>\n',ABOUT_NAME_REMOTE);
end
STIM_ENABLE = true;
INTAN_ENABLE = true;
if INTAN_ENABLE
intanTcpClient = tcpclient("127.0.0.1", 5000);
intanTcpClient.configureCallback("byte", 1, @(src,~)fprintf(read(src)));
intan.enablePortChannelBatch(intanTcpClient, AMPLIFIER_PORT, AMPLIFIER_CHANNELS, 'EnableTCP', false);
intan.enableAudio(intanTcpClient);
intan.enableDigIn(intanTcpClient);
end
%% Initialize interfaces
[client, am4100, logger] = initInterfaces( ...
'UseAM4100', STIM_ENABLE, ...
'UseIntan', INTAN_ENABLE, ...
'Subject', SUBJECT_NAME, ...
'Sweep', START_SWEEP, ...
'Block', START_BLOCK, ...
'AddressTMSi', IPV4_ADDRESS_TMSI, ...
'AddressAM4100', IPV4_ADDRESS_AM4100, ...
'AddressIntan', IPV4_ADDRESS_INTAN, ...
'IntanClient', intanTcpClient);
%% Run stimulation/recording sweep via GUI
fig = init_stim_rec_sweep_gui(client, am4100, logger);