-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCopyConvertPhysio.m
53 lines (31 loc) · 1.23 KB
/
CopyConvertPhysio.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
clear,clc
addpath('/home/alexandresayal/Documents/MATLAB/jsonlab/')
%% Settings
subID = '01';
bidsFolder = '/home/alexandresayal/Desktop/BIDS-VPMB/';
rawPhysioFolder = '/media/alexandresayal/DATA_1TB/RAW_DATA_VP_MBEPI_Codev0.5/VPMBAUS01_LOGS';
%% Fetch runs and acquisition times
D1 = dir(fullfile(bidsFolder,['sub-' subID],'func','*_bold.json'));
J = struct();
for ii = 1:length(D1)
aux = loadjson( fullfile(D1(ii).folder,D1(ii).name) );
J(ii).name = D1(ii).name(1:end-10);
J(ii).time = aux.AcquisitionTime;
end
[~,index] = sortrows({J.time}.'); J = J(index); clear index; % sort by time
%% Fetch physiofiles
D2 = dir( fullfile(rawPhysioFolder,'*.log') );
% sort list anyway
[~,index] = sortrows({D2.name}.'); D2 = D2(index); clear index;
%% Copy files to BIDS directory
% check number of runs match
% copy
% convert (but how?)
%%
cmd1 = sprintf('physio2bidsphysio --infiles %s %s %s --bidsprefix %s -v',...
fullfile(rawPhysioFolder,D2(1).name),...
fullfile(rawPhysioFolder,D2(2).name),...
fullfile(rawPhysioFolder,D2(3).name),...
fullfile(bidsFolder,['sub-' subID],'func',J(1).name) )
%%
%system(cmd1)