Skip to content

Commit c0ec1c1

Browse files
authored
Merge pull request #31 from Remi-Gau/remi-doc
update doc
2 parents c5c3f83 + 35aa098 commit c0ec1c1

File tree

7 files changed

+116
-52
lines changed

7 files changed

+116
-52
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
*.tsv
99
*.mat
1010

11+
check_my_code_report.txt

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ before_install:
1313
- travis_retry sudo apt-get -y -qq update
1414
- travis_retry sudo apt-get -y install octave
1515
- travis_retry sudo apt-get -y install liboctave-dev
16-
- travis_retry sudo apt-get -y install nodejs
17-
- travis_retry sudo apt-get -y install npm
16+
# - travis_retry sudo apt-get -y install nodejs
17+
# - travis_retry sudo apt-get -y install npm
1818

1919
install:
2020
# Install JSONio

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ expParameters = createFilename(cfg, expParameters);
6666
% and add some more in this case (Speed and is_Fixation)
6767
logFile = saveEventsFile('open', expParameters, [], 'Speed', 'is_Fixation');
6868
69+
% to initialize a stim file in case you want to store the info about the stimuli in it
70+
stimFile = saveEventsFile('open_stim', expParameters, []);
71+
6972
% create the information about 2 events that we want to save
7073
logFile(1,1).onset = 2;
7174
logFile(1,1).trial_type = 'motion_up';
@@ -184,3 +187,24 @@ Here are the naming templates used.
184187
- Eyetracker
185188

186189
`sub-<participant_label>[_ses-<label>][_acq-<label>]_task-<task_label>_eyetrack.<manufacturer_specific_extension>`
190+
191+
### Contributors ✨
192+
193+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
194+
195+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
196+
<!-- prettier-ignore-start -->
197+
<!-- markdownlint-disable -->
198+
<table>
199+
<tr>
200+
<td align="center"><a href="https://github.com/CerenB"><img src="https://avatars1.githubusercontent.com/u/10451654?v=4" width="100px;" alt=""/><br /><sub><b>CerenB</b></sub></a><br /><a href="https://github.com/cpp-lln-lab/CPP_BIDS/commits?author=CerenB" title="Code">💻</a> <a href="#design-CerenB" title="Design">🎨</a> <a href="https://github.com/cpp-lln-lab/CPP_BIDS/commits?author=CerenB" title="Documentation">📖</a></td>
201+
<td align="center"><a href="https://github.com/marcobarilari"><img src="https://avatars3.githubusercontent.com/u/38101692?v=4" width="100px;" alt=""/><br /><sub><b>marcobarilari</b></sub></a><br /><a href="https://github.com/cpp-lln-lab/CPP_BIDS/commits?author=marcobarilari" title="Code">💻</a> <a href="#design-marcobarilari" title="Design">🎨</a> <a href="https://github.com/cpp-lln-lab/CPP_BIDS/commits?author=marcobarilari" title="Documentation">📖</a></td>
202+
<td align="center"><a href="https://remi-gau.github.io/"><img src="https://avatars3.githubusercontent.com/u/6961185?v=4" width="100px;" alt=""/><br /><sub><b>Remi Gau</b></sub></a><br /><a href="https://github.com/cpp-lln-lab/CPP_BIDS/commits?author=Remi-Gau" title="Code">💻</a> <a href="#design-Remi-Gau" title="Design">🎨</a> <a href="https://github.com/cpp-lln-lab/CPP_BIDS/commits?author=Remi-Gau" title="Documentation">📖</a></td>
203+
</tr>
204+
</table>
205+
206+
<!-- markdownlint-enable -->
207+
<!-- prettier-ignore-end -->
208+
<!-- ALL-CONTRIBUTORS-LIST:END -->
209+
210+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

checkCFG.m

+15-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,26 @@
1414
end
1515

1616
% set empty values for a series of field if they have not been specified
17+
% 'ce'
18+
% 'dir' For BIDS file naming: phase encoding direction of acquisition for fMRI
19+
% 'rec' For BIDS file naming: reconstruction of fMRI images
20+
% 'echo' For BIDS file naming: echo fMRI images
21+
% 'acq' For BIDS file naming: acquisition of fMRI images
22+
% 'subjectGrp' in case no group was provided
23+
% 'sessionNb' in case no session was provided
24+
1725
fields2Check = { ...
1826
'ce', ...
19-
'dir', ... % For BIDS file naming: phase encoding direction of acquisition for fMRI
20-
'rec', ... % For BIDS file naming: reconstruction of fMRI images
21-
'echo', ... % For BIDS file naming: echo fMRI images
22-
'acq' % For BIDS file naming: acquisition of fMRI images
23-
};
27+
'dir', ...
28+
'rec', ...
29+
'echo', ...
30+
'acq', ...
31+
'subjectGrp', ...
32+
'sessionNb'};
2433

2534
fields2CheckFalse = { ...
2635
'eyeTracker'
27-
}
36+
};
2837

2938
for iField = 1:numel(fields2Check)
3039
if ~isfield(expParameters, fields2Check{iField})

tests/test_createFilename.m

+31-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
function test_createFilename()
2-
32
% test for filename creation and their directories
43

54
%% check directory and filename creation (PC)
65

6+
%%% set up part
7+
78
expParameters.subjectGrp = '';
89
expParameters.subjectNb = 1;
910
expParameters.sessionNb = 1;
@@ -14,32 +15,40 @@ function test_createFilename()
1415
cfg.eyeTracker = false;
1516
cfg.device = 'PC';
1617

18+
% set up the output directories
1719
outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
20+
expParameters.outputDir = outputDir;
1821

1922
behDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'beh');
2023
eyetrackerDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'eyetracker');
2124

22-
expParameters.outputDir = outputDir;
2325
expParameters = checkCFG(cfg,expParameters);
24-
2526
expParameters = createFilename(cfg,expParameters);
2627

28+
%%% test part
29+
30+
% make sure the beh dir is created
2731
assert(exist(behDir, 'dir')==7)
2832

2933
% make sure the eyetracker dir is not created
30-
assert(exist(eyetrackerDir, 'dir')==0)
34+
assert(exist(eyetrackerDir, 'dir')==0)
3135

36+
% make sure the events filename is created
3237
assert(strcmp(...
33-
expParameters.fileName.events, ...
34-
['sub-001_ses-001_task-testtask_run-001_events_date-' expParameters.date '.tsv']));
38+
expParameters.fileName.events, ...
39+
['sub-001_ses-001_task-testtask_run-001_events_date-' expParameters.date '.tsv']));
40+
41+
% make sure the stim filename is created
3542
assert(strcmp(...
36-
expParameters.fileName.stim, ...
37-
['sub-001_ses-001_task-testtask_run-001_stim_date-' expParameters.date '.tsv']));
38-
43+
expParameters.fileName.stim, ...
44+
['sub-001_ses-001_task-testtask_run-001_stim_date-' expParameters.date '.tsv']));
45+
3946
%% check directory and filename creation (fMRI and eye tracker)
4047

4148
clear
4249

50+
%%% set up part
51+
4352
expParameters.subjectGrp = 'ctrl';
4453
expParameters.subjectNb = 2;
4554
expParameters.sessionNb = 2;
@@ -58,13 +67,21 @@ function test_createFilename()
5867
expParameters = checkCFG(cfg,expParameters);
5968
expParameters = createFilename(cfg,expParameters);
6069

70+
%%% test part
71+
72+
% make sure the func dir is created
6173
assert(exist(funcDir, 'dir')==7)
74+
75+
% make sure the eyetracker dir is created
6276
assert(exist(eyetrackerDir, 'dir')==7)
77+
78+
% make sure the events filename is created
6379
assert(strcmp(expParameters.fileName.base, 'sub-ctrl002_ses-002_task-testtask'))
6480
assert(strcmp(...
65-
expParameters.fileName.events, ...
66-
['sub-ctrl002_ses-002_task-testtask_run-002_events_date-' expParameters.date '.tsv']));
67-
81+
expParameters.fileName.events, ...
82+
['sub-ctrl002_ses-002_task-testtask_run-002_events_date-' expParameters.date '.tsv']));
83+
84+
% make sure the eyetracker filename is created
6885
assert(strcmp(...
69-
expParameters.fileName.eyetracker, ...
70-
['sub-ctrl002_ses-002_task-testtask_run-002_eyetrack_date-' expParameters.date '.edf']));
86+
expParameters.fileName.eyetracker, ...
87+
['sub-ctrl002_ses-002_task-testtask_run-002_eyetrack_date-' expParameters.date '.edf']));

tests/test_saveEventsFile.m

+13-11
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ function test_saveEventsFile()
1919
expParameters = checkCFG(cfg,expParameters);
2020
expParameters = createFilename(cfg,expParameters);
2121

22-
23-
2422
%% create the events and stim files
2523

2624
logFile = saveEventsFile('open', expParameters, [], 'Speed', 'is_Fixation');
2725

2826
stimFile = saveEventsFile('open_stim', expParameters, []);
2927

30-
% ---- test section
28+
%%% test section
3129

3230
fileName = fullfile(expParameters.outputDir, expParameters.modality, expParameters.fileName.events);
3331
stimFileName = fullfile(expParameters.outputDir, expParameters.modality, expParameters.fileName.stim);
@@ -60,23 +58,27 @@ function test_saveEventsFile()
6058

6159
saveEventsFile('save', expParameters, logFile, 'speed', 'is_fixation');
6260

63-
6461
% close the file
6562
saveEventsFile('close', expParameters, logFile);
6663

67-
68-
% ---- test section
64+
%%% test section
6965

7066
% check the extra columns of the header and some of the content
7167

7268
FID = fopen(fileName, 'r');
7369
C = textscan(FID,'%s%s%s%s%s','Delimiter', '\t', 'EndOfLine', '\n');
7470

75-
assert(isequal(C{4}{1}, 'speed')); % check header
71+
% check header
72+
assert(isequal(C{4}{1}, 'speed'));
73+
74+
% check that empty values are entered as NaN
75+
assert(isequal(C{4}{2}, 'NaN'));
7676

77-
assert(isequal(C{4}{2}, 'NaN')); % check that empty values are entered as NaN
78-
assert(isequal(C{4}{4}, 'NaN')); % check that missing fields are entered as NaN
77+
% check that missing fields are entered as NaN
78+
assert(isequal(C{4}{4}, 'NaN'));
7979

80-
assert(isequal(str2double(C{4}{3}), 2)); % check values entered properly
80+
% check values entered properly
81+
assert(isequal(str2double(C{4}{3}), 2));
8182

82-
assert(isequal(str2double(C{5}{4}), 3)); % check values entered properly
83+
% check values entered properly
84+
assert(isequal(str2double(C{5}{4}), 3));

userInputs.m

+30-19
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,65 @@
1-
function [expParameters] = userInputs(cfg, expParameters)
1+
function [expParameters] = userInputs(cfg, expParameters, askGrpSess)
22
% Get subject, run and session number and make sure they are
33
% positive integer values
4+
%
5+
% skipGrpSess
6+
% a 1 X 2 array of booleans (default is [true true] ):
7+
% - the first value set to false will skip asking for the participants
8+
% group
9+
% - the second value set to false will skip asking for the session
410

511
if nargin<1
612
cfg.debug = false;
713
end
8-
914
if nargin<2
1015
expParameters = [];
1116
end
17+
if nargin<3
18+
askGrpSess = [true true];
19+
end
1220

1321

22+
% When in debug more this function returns some dummy values
1423
if cfg.debug
15-
1624
subjectGrp = 'ctrl';
1725
subjectNb = 666;
1826
runNb = 666;
1927
sessionNb = 666;
20-
28+
29+
% Otherwise it prompts the user for some information
2130
else
22-
23-
subjectGrp = lower(input('Enter subject group (leave empty if none): ', 's'));
24-
31+
32+
% subject group
33+
if askGrpSess(1)
34+
subjectGrp = lower(input('Enter subject group (leave empty if none): ', 's'));
35+
end
36+
37+
% the subject number
2538
subjectNb = str2double(input('Enter subject number (1-999): ', 's') );
2639
subjectNb = checkInput(subjectNb);
27-
28-
sessionNb = str2double(input('Enter the session (i.e day - 1-999)) number: ', 's'));
29-
sessionNb = checkInput(sessionNb);
30-
40+
41+
% the session number
42+
if askGrpSess(2)
43+
sessionNb = str2double(input('Enter the session (i.e day - 1-999)) number: ', 's'));
44+
sessionNb = checkInput(sessionNb);
45+
end
46+
47+
% the run number
3148
runNb = str2double(input('Enter the run number (1-999): ', 's'));
3249
runNb = checkInput(runNb);
33-
50+
3451
end
3552

36-
3753
expParameters.subjectGrp = subjectGrp;
3854
expParameters.subjectNb = subjectNb;
3955
expParameters.sessionNb = sessionNb;
4056
expParameters.runNb = runNb;
4157

42-
4358
end
4459

45-
4660
function input2check = checkInput(input2check)
47-
48-
61+
% this function checks the input to makes sure the user enters a positive integer
4962
while isnan(input2check) || fix(input2check) ~= input2check || input2check<0
5063
input2check = str2double(input('Please enter a positive integer: ', 's'));
5164
end
52-
53-
5465
end

0 commit comments

Comments
 (0)