Skip to content

Commit faf11ef

Browse files
committed
final touches
1 parent 9658b71 commit faf11ef

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ before_install:
1919

2020

2121
install:
22-
# Install JSONio
23-
#- travis_retry git clone git://github.com/gllmflndn/JSONio.git --depth 1
22+
# make octave file for JSONio
2423
- cd lib/JSONio; mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS; cd ../..
25-
#- octave $OCTFLAGS --eval "addpath (fullfile (pwd, 'JSONio')); savepath ();"
26-
# Install BIDS-MATLAB
2724
- octave $OCTFLAGS --eval "addpath (pwd); savepath ();"
2825
# Install BIDS-Validator
2926
- sudo npm install -g bids-validator
@@ -41,5 +38,5 @@ jobs:
4138
name: "miss_hit linter" # names the second job
4239
- stage: "BIDS validator"
4340
name: "create and check dataset" # names the second job
44-
- script: octave $OCTFLAGS --eval "makeRawDataset_test" && bids-validator `pwd`/../output/rawdata/ --ignoreNiftiHeaders
41+
script: octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/../output/rawdata/ --ignoreNiftiHeaders
4542

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,17 @@ logFile.extraColumns = {'Speed', 'is_Fixation'};
127127
128128
[cfg, expParameters] = createFilename(cfg, expParameters);
129129
130-
% dummy call to initialize the logFile variable
131-
logFile = saveEventsFile('open', expParameters, logFile);
130+
% initialize the logFile variable
131+
[logFile] = saveEventsFile('init', expParameters, logFile);
132132
133133
% set the real length we really want
134134
logFile.extraColumns.Speed.length = 12;
135135
136-
% actual inititalization
136+
% open the file
137137
logFile = saveEventsFile('open', expParameters, logFile);
138138
```
139139

140+
140141
## Functions descriptions
141142

142143
### userInputs

saveEventsFile.m

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@
171171
end
172172

173173
function logFile = initializeFile(expParameters, logFile)
174+
175+
createDataDictionary(expParameters, logFile);
174176

175177
logFile = initializeExtraColumns(logFile);
176178

@@ -214,36 +216,6 @@ function printHeaderExtraColumns(logFile)
214216

215217
end
216218

217-
function data = checkInput(data, expectedLength)
218-
% check the data to write
219-
% default will be 'n/a' for chars and NaN for numeric data
220-
% for numeric data that don't have the expected length, it will be padded with NaNs
221-
222-
if nargin < 2
223-
expectedLength = [];
224-
end
225-
226-
if ischar(data) && isempty(data) || strcmp(data, ' ')
227-
data = 'n/a';
228-
elseif isempty(data)
229-
% important to not set this to n/a as we still need to check if this
230-
% numeric valur has the right length and needs to be nan padded
231-
data = nan;
232-
end
233-
234-
if islogical(data) && data
235-
data = 'true';
236-
elseif islogical(data) && ~data
237-
data = 'false';
238-
end
239-
240-
if ~isempty(expectedLength) && isnumeric(data) && max(size(data)) < expectedLength
241-
padding = expectedLength - max(size(data));
242-
data(end + 1:end + padding) = nan(1, padding);
243-
end
244-
245-
end
246-
247219
function logFile = checkExtracolumns(logFile, iEvent)
248220
% loops through the extra columns
249221
% if the field we are looking for does not exist or is empty in the
@@ -277,6 +249,40 @@ function printHeaderExtraColumns(logFile)
277249

278250
end
279251

252+
function data = checkInput(data, expectedLength)
253+
% check the data to write
254+
% default will be 'n/a' for chars and NaN for numeric data
255+
% for numeric data that don't have the expected length, it will be padded with NaNs
256+
257+
if nargin < 2
258+
expectedLength = [];
259+
end
260+
261+
if islogical(data) && data
262+
data = 'true';
263+
elseif islogical(data) && ~data
264+
data = 'false';
265+
end
266+
267+
268+
if ischar(data) && isempty(data) || strcmp(data, ' ')
269+
data = 'n/a';
270+
elseif isempty(data)
271+
% important to not set this to n/a as we still need to check if this
272+
% numeric valur has the right length and needs to be nan padded
273+
data = nan;
274+
end
275+
276+
if ~isempty(expectedLength) && isnumeric(data) && max(size(data)) < expectedLength
277+
padding = expectedLength - max(size(data));
278+
data(end + 1:end + padding) = nan(1, padding);
279+
elseif ~isempty(expectedLength) && isnumeric(data) && max(size(data)) > expectedLength
280+
data = data(1:expectedLength);
281+
warning('A field for this event is longer than expected. Truncating the extra values.')
282+
end
283+
284+
end
285+
280286
function printExtraColumns(logFile, iEvent)
281287
% loops through the extra columns and print them
282288

tests/test_makeRawDataset.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ function test_makeRawDataset()
2727

2828
cfg.testingDevice = 'mri';
2929

30-
cfg.testingDevice = 'pc';
31-
3230
logFile.extraColumns.Speed.length = 1;
3331
logFile.extraColumns.LHL24.length = 3;
3432
logFile.extraColumns.is_Fixation.length = 1;
@@ -40,7 +38,6 @@ function test_makeRawDataset()
4038
% create the events file and header
4139
logFile = saveEventsFile('open', expParameters, logFile);
4240

43-
createDataDictionary(expParameters, logFile);
4441
createBoldJson(expParameters);
4542
createDatasetDescription(expParameters);
4643

0 commit comments

Comments
 (0)