Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions manualTests/test_createDataDictionary.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function test_createDataDictionaryBasic()
funcDir = fullfile(outputDir, 'source', 'sub-001', 'ses-001', 'func');

jsonFilename = ['sub-001_ses-001_task-testtask_run-001_events_date-' ...
cfg.fileName.date '.json'];
cfg.fileName.date '.json'];

% test
assertTrue(exist(fullfile(funcDir, jsonFilename), 'file') == 2);
Expand All @@ -47,7 +47,7 @@ function test_createDataDictionaryBasic()

% data to test against
expectedStruct = bids.util.jsondecode( ...
fullfile(pwd, 'testData', 'eventsDataDictionary.json'));
fullfile(pwd, 'testData', 'eventsDataDictionary.json'));

% test
assertTrue(isequal(expectedStruct, actualStruct));
Expand Down
8 changes: 4 additions & 4 deletions manualTests/test_createJson.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ function test_createJsonExtra()
fileName = strrep(fileName, '.tsv', '.json');

actualStruct = bids.util.jsondecode(fullfile( ...
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
fileName));
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
fileName));

% data to test against
expectedStruct = bids.util.jsondecode( ...
fullfile(pwd, 'testData', 'extra_bold.json'));
fullfile(pwd, 'testData', 'extra_bold.json'));

% test
assertEqual(expectedStruct, actualStruct);
Expand Down
28 changes: 14 additions & 14 deletions manualTests/test_makeRawDataset.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,16 @@ function test_makeRawDataset()
boldFilename = 'sub-001_ses-001_task-testtask_run-001_bold.nii.gz';

copyfile( ...
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(funcDir, boldFilename));
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(funcDir, boldFilename));

boldFilename = ['sub-001_ses-001_task-rest', ...
'_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ...
'_run-001_echo-1_bold.nii.gz'];
'_acq-newTYpe_ce-test_dir-yPos_rec-fastRecon', ...
'_run-001_echo-1_bold.nii.gz'];

copyfile( ...
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(funcDir, boldFilename));
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(funcDir, boldFilename));

eegDir = fullfile(subjectDir, 'eeg');
megDir = fullfile(subjectDir, 'meg');
Expand All @@ -227,20 +227,20 @@ function test_makeRawDataset()
behFilename = 'sub-001_ses-001_task-easyTargetPractice_run-001_beh.tsv';

copyfile( ...
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(eegDir, eegFilename));
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(eegDir, eegFilename));

copyfile( ...
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(megDir, megFilename));
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(megDir, megFilename));

copyfile( ...
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(ieegDir, ieegFilename));
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(ieegDir, ieegFilename));

copyfile( ...
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(behDir, behFilename));
fullfile('dummyData', 'dummyData.nii.gz'), ...
fullfile(behDir, behFilename));

%% actually do the conversion of the source data thus created
clear;
Expand Down
6 changes: 3 additions & 3 deletions src/checkCFG.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
fieldsToSet.fileName.dateFormat = 'yyyymmddHHMM';

fieldsToSet.dir.output = fullfile( ...
fileparts(mfilename('fullpath')), ...
'..', ...
'output');
fileparts(mfilename('fullpath')), ...
'..', ...
'output');

fieldsToSet.subject.askGrpSess = [true true];
fieldsToSet.subject.sessionNb = 1; % in case no session was provided
Expand Down
12 changes: 6 additions & 6 deletions src/convertSourceToRaw.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ function convertSourceToRaw(cfg)

% add dummy README and CHANGE file
copyfile(fullfile( ...
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'README'), ...
sourceDir);
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'README'), ...
sourceDir);
copyfile(fullfile( ...
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'CHANGES'), ...
sourceDir);
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', 'CHANGES'), ...
sourceDir);
copyfile(fullfile( ...
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', '.bidsignore'), ...
sourceDir);
fileparts(mfilename('fullpath')), '..', 'manualTests', 'dummyData', '.bidsignore'), ...
sourceDir);

copyfile(sourceDir, rawDir);

Expand Down
28 changes: 14 additions & 14 deletions src/createDataDictionary.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ function createDataDictionary(cfg, logFile)

opts.Indent = ' ';

fileName = strrep(cfg.fileName.events, '.tsv', '.json');
fileName = strrep(logFile.filename, '.tsv', '.json');

fileName = fullfile( ...
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
fileName);
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
fileName);

jsonContent = struct( ...
'onset', struct( ...
'Description', 'time elapsed since experiment start', ...
'Unit', 's'), ...
'trial_type', struct( ...
'Description', 'types of trial', ...
'Levels', ''), ...
'duration', struct( ...
'Description', 'duration of the event or the block', ...
'Unit', 's') ...
);
'onset', struct( ...
'Description', 'time elapsed since experiment start', ...
'Unit', 's'), ...
'trial_type', struct( ...
'Description', 'types of trial', ...
'Levels', ''), ...
'duration', struct( ...
'Description', 'duration of the event or the block', ...
'Unit', 's') ...
);

% transfer content of extra fields to json content
namesExtraColumns = returnNamesExtraColumns(logFile);
Expand Down
4 changes: 2 additions & 2 deletions src/createDatasetDescription.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function createDatasetDescription(cfg)
opts.Indent = ' ';

fileName = fullfile( ...
cfg.dir.output, 'source', ...
'dataset_description.json');
cfg.dir.output, 'source', ...
'dataset_description.json');

jsonContent = cfg.bids.datasetDescription;

Expand Down
62 changes: 31 additions & 31 deletions src/createFilename.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@

% output dir
cfg.dir.outputSubject = fullfile ( ...
cfg.dir.output, ...
'source', ...
['sub-' subjectGrp, sprintf(pattern, subjectNb)], ...
['ses-', sprintf(pattern, sessionNb)]);
cfg.dir.output, ...
'source', ...
['sub-' subjectGrp, sprintf(pattern, subjectNb)], ...
['ses-', sprintf(pattern, sessionNb)]);

[~, ~, ~] = mkdir(cfg.dir.output);
[~, ~, ~] = mkdir(cfg.dir.outputSubject);
Expand All @@ -102,22 +102,22 @@
%% MRI
% set values for the suffixes for the different fields in the BIDS name
fields2Check = { ...
'acquisition', ...
'contrastEnhancement', ...
'echo', ...
'phaseEncodingDirection', ...
'reconstruction', ...
'recording' ...
};
'acquisition', ...
'contrastEnhancement', ...
'echo', ...
'phaseEncodingDirection', ...
'reconstruction', ...
'recording' ...
};

targetFields = { ...
'acq', ...
'ce', ...
'echo', ...
'dir', ...
'rec', ...
'recording' ...
};
'acq', ...
'ce', ...
'echo', ...
'dir', ...
'rec', ...
'recording' ...
};

for iField = 1:numel(fields2Check)

Expand Down Expand Up @@ -158,31 +158,31 @@
thisDate = cfg.fileName.date;

cfg.fileName.datasetDescription = fullfile ( ...
cfg.dir.output, ...
'dataset_description.json');
cfg.dir.output, ...
'dataset_description.json');

% create base fileName
fileNameBase = ...
['sub-', subjectGrp, sprintf(pattern, subjectNb), ...
'_ses-', sprintf(pattern, sessionNb), ...
'_task-', taskName];
'_ses-', sprintf(pattern, sessionNb), ...
'_task-', taskName];
cfg.fileName.base = fileNameBase;

switch modality

case 'func'

basename = [fileNameBase, ...
acqSuffix, ceSuffix, ...
dirSuffix, recSuffix, ...
runSuffix, echoSuffix];
acqSuffix, ceSuffix, ...
dirSuffix, recSuffix, ...
runSuffix, echoSuffix];

case 'beh'

basename = ...
[fileNameBase, ...
acqSuffix, ...
runSuffix];
acqSuffix, ...
runSuffix];

otherwise

Expand All @@ -206,18 +206,18 @@ function talkToMe(cfg)
if cfg.verbose > 0

fprintf(1, '\nData will be saved in this directory:\n\t%s\n', ...
fullfile(cfg.dir.outputSubject, cfg.fileName.modality));
fullfile(cfg.dir.outputSubject, cfg.fileName.modality));

fprintf(1, '\nData will be saved in this file:\n\t%s\n', ...
cfg.fileName.events);
cfg.fileName.events);

if cfg.eyeTracker.do

fprintf(1, '\nEyetracking data will be saved in this directory:\n\t%s\n', ...
fullfile(cfg.dir.outputSubject, 'eyetracker'));
fullfile(cfg.dir.outputSubject, 'eyetracker'));

fprintf(1, '\nEyetracking data will be saved in this file:\n\t%s\n', ...
cfg.fileName.eyetracker);
cfg.fileName.eyetracker);

end

Expand Down
12 changes: 6 additions & 6 deletions src/createJson.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ function createJson(varargin)
fileName = strrep(fileName, '.tsv', '.json');

fileName = fullfile( ...
cfg.dir.outputSubject, ...
modality, ...
fileName);
cfg.dir.outputSubject, ...
modality, ...
fileName);

%% add content of extraInfo to the JSON content

Expand Down Expand Up @@ -115,11 +115,11 @@ function errorCreateJson(identifier, varargin)

case 'wrongInputType'
errorStruct.message = ['The second input must be a string (modality)' ...
'or a structure (extraInfo)'];
'or a structure (extraInfo)'];
case 'wrongModalityInput'
errorStruct.message = sprintf(['The given modality is not valid: %s.\n', ...
'Only the following string are accepted: beh, func, eeg, ieeg, meg'], ...
varargin{1});
'Only the following string are accepted: beh, func, eeg, ieeg, meg'], ...
varargin{1});

end

Expand Down
28 changes: 14 additions & 14 deletions src/saveEventsFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@
% Initialize txt logfiles and empty fields for the standard BIDS
% event file
logFile(1).fileID = fopen( ...
fullfile( ...
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
logFile.filename), ...
'w');
fullfile( ...
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
logFile.filename), ...
'w');

% print the basic BIDS columns
fprintf(logFile(1).fileID, '%s\t%s\t%s', 'onset', 'duration', 'trial_type');
Expand Down Expand Up @@ -219,7 +219,7 @@ function printHeaderExtraColumns(logFile)

if ~ischar(data) && any(isnan(data))
warning('saveEventsFile:missingData', ...
'Missing some %s data for this event.', namesExtraColumns{iExtraColumn});
'Missing some %s data for this event.', namesExtraColumns{iExtraColumn});

if cfg.verbose > 1
disp(logFile(iEvent));
Expand Down Expand Up @@ -269,7 +269,7 @@ function printHeaderExtraColumns(logFile)
data(end + 1:end + padding) = nan(1, padding);
elseif ~isempty(expectedLength) && isnumeric(data) && max(size(data)) > expectedLength
warning('saveEventsFile:arrayTooLong', ...
'A field for this event is longer than expected. Truncating the extra values.');
'A field for this event is longer than expected. Truncating the extra values.');
data = data(1:expectedLength);
end

Expand All @@ -293,9 +293,9 @@ function printHeaderExtraColumns(logFile)
any(isempty({onset duration}))

warning('saveEventsFile:emptyEvent', ...
'\nSkipping saving this event.\n onset: %s \n duration: %s\n', ...
onset, ...
duration);
'\nSkipping saving this event.\n onset: %s \n duration: %s\n', ...
onset, ...
duration);

else

Expand Down Expand Up @@ -395,10 +395,10 @@ function talkToMe(cfg, logFile)
if cfg.verbose > 0

fprintf(1, '\nData were saved in this file:\n\n%s\n\n', ...
fullfile( ...
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
logFile.filename));
fullfile( ...
cfg.dir.outputSubject, ...
cfg.fileName.modality, ...
logFile.filename));

end

Expand Down
Loading