-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspm2bv.m
43 lines (24 loc) · 851 Bytes
/
spm2bv.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
function spm2bv( names , onsets , durations , filename )
%SPM2BV transform 'names', 'onsets', 'durations' cells (for SPM) to
%BrainVoyager *.prt text file
% CENIR-ICM , 2015
%% Open file in write mod
fileID = fopen( [ filename '.prt' ] , 'w' , 'n' , 'UTF-8' );
if fileID < 0
error('%d cannot be opened', filename)
end
%% Fill the file
fprintf( fileID , 'NrOfConditions: %d\r\n' , length(names) );
fprintf( fileID , '\r\n' );
for n = 1 : length(names)
fprintf( fileID , '%s\r\n' , names{n} );
fprintf( fileID , '%d\r\n' , length(onsets{n}) );
for o = 1 : length(onsets{n})
fprintf( fileID , '%f\t%f\r\n' , onsets{n}(o) , onsets{n}(o) + durations{n}(o) );
end
fprintf( fileID , '\r\n' );
end
%% Close the file
fclose( fileID );
end