-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMoBIDS_handson_2_touchup.m
60 lines (41 loc) · 2.76 KB
/
MoBIDS_handson_2_touchup.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
% There is no need to be allergic to all hacky solutions
% "Manual" touch-up of files might be necessary or easier at times
%--------------------------------------------------------------------------
bidsFolder = 'P:\Sein_Jeung\Project_BIDS\Workshops\Workshop_2024_MoBI\Hands-on\data\bidsdata';
% touch up the output .json files : remove autogenerated README fields
%--------------------------------------------------------------------------
eegJSON = fullfile(bidsFolder, 'sub-001\eeg\sub-001_task-SpotRotation_eeg.json');
file = ft_read_json(eegJSON);
file = rmfield(file, 'README');
ft_write_json(eegJSON, file)
motionJSON = fullfile(bidsFolder, 'sub-001\motion\sub-001_task-SpotRotation_tracksys-HTCVive_motion.json');
file = ft_read_json(motionJSON);
file = rmfield(file, 'README');
ft_write_json(motionJSON, file)
% touch up the output channels.tsv file
%--------------------------------------------------------------------------
motionChannels = fullfile(bidsFolder, 'sub-001\motion\sub-001_task-SpotRotation_tracksys-HTCVive_channels.tsv');
file = ft_read_tsv(motionChannels);
orntInds = find(contains(file.type, 'ORNT'));
file.component(orntInds) = {'x', 'y', 'z', 'w'}; % modify column entry
file2 = file(:,{'name' 'component' 'type', 'tracked_point', 'units'}); % reorder columns
ft_write_tsv(motionChannels,file2)
% add channels.json file to provide information about refernce frames
%--------------------------------------------------------------------------
motionChannelsJSON = fullfile(bidsFolder, 'sub-001\motion\sub-001_task-SpotRotation_tracksys-HTCVive_channels.json');
file = [];
file.reference_frame.LongName = "reference_frame";
file.reference_frame.Description = "reference frame in which the channels is represented.";
file.reference_frame.Levels.global.Description = "room-fixed global reference frame";
file.reference_frame.Levels.global.SpatialAxes = "ARS";
file.reference_frame.Levels.global.RotationOrder = "ZXY";
file.reference_frame.Levels.global.RotationRule = "left-hand";
ft_write_json(motionChannelsJSON , file)
% Exercise in case you did not bring own data
%--------------------------------------------------------------------------
% A. Try using BIDS-validator (https://bids-standard.github.io/bids-validator/) on the data set and fix errors
% B. Create BIDS output for participant 2 using the same script
% C. Try modifying the entries in 'sub-001_task-SpotRotation_channels.tsv'
% Electrodes 'G16' and 'G32' were vertical EOG electrodes with type 'EOG'
% D. Try importing both 'control_body.xdf' and 'control_joy.xdf' as two
% different sessions