Comments (18)
those are for instance the input you provide to expParams when you run userInput, or in your getParams/setParam script, you add "task". So in order to this test function working or not, Remi defined them. Just for illustration. IMHO.
from cpp_bids.
yeah i thought about the dummy call too but didn't think of actual initialization :D
thanks!
feel free to close this issue
from cpp_bids.
This would be the basic idea on how this function should work.
I want to minimize how many arguments are passed around so I am hiding everything in a structure.
If this behavior makes sense then I can write the tests that will make sure this function works that way.
usage by default
expParameters.subjectGrp = '';
expParameters.subjectNb = 1;
expParameters.sessionNb = 1;
expParameters.runNb = 1;
expParameters.task = 'testtask';
expParameters.outputDir = outputDir;
[cfg, expParameters] = createFilename(cfg, expParameters);
% define the extra columns: they will be added to the tsv files in the order the user input them,
% though we could have an extra field where we can specify the order of the
% columns to avoid suprises.
logFile.extraColumns.sequenceNum = 1; % will set 1 columns with name sequenceNum
logFile.extraColumns.LHL24 = 12; % will set 12 columns with names LHL24-01, LHL24-02, ...
% create file and get file ID
logFile = saveEventsFile('open', expParameters, logFile);
% event 1
logFile(1, 1).onset = 2;
logFile(1, 1).trial_type = 'blues';
logFile(1, 1).duration = 12;
logFile(1, 1).sequenceNum = 2;
logFile(1, 1).LHL24 = 1:12;
% event 2
logFile(2, 1).onset = 3;
logFile(2, 1).trial_type = 'jazz';
logFile(2, 1).duration = 34;
logFile(2, 1).sequenceNum = 3;
logFile(1, 1).LHL24 = rand(1:12);
saveEventsFile('save', expParameters, logFile);
saveEventsFile('close', expParameters, logFile);
usage combined with CPP_PTB
expParameters.subjectGrp = '';
expParameters.subjectNb = 1;
expParameters.sessionNb = 1;
expParameters.runNb = 1;
expParameters.task = 'testtask';
expParameters.outputDir = outputDir;
[cfg, expParameters] = createFilename(cfg, expParameters);
% define the extra columns: they will be added to the tsv files in the order the user input them,
% though we could have an extra field where we can specify the order of the
% columns to avoid suprises.
logFile.extraColumns.sequenceNum = 1; % will set 1 columns with name sequenceNum
logFile.extraColumns.LHL24 = 12; % will set 12 columns with names LHL24-01, LHL24-02, ...
% create file and get file ID
logFile = saveEventsFile('open', expParameters, logFile);
% get responses with CPP_PTB
responseEvents = getResponse('check', deviceNumber, cfg);
% update responseEvents with the relevant info
responseEvents.fileID = logFile.fileID;
responseEvents.extraColumns = logFile.extraColumns;
for iEvent = 1:numel(responseEvents)
responseEvents(iEvent, 1).sequenceNum = % insert the right thing here;
responseEvents(iEvent, 1).LHL24 = % insert the right thing here;
end
saveEventsFile('save', expParameters, responseEvents);
saveEventsFile('close', expParameters, logFile);
from cpp_bids.
to me, yes it does make sense.
from cpp_bids.
and this output is good for BIDS? session is empty:
sub-001_ses-_task-RhythmCategFT_run-001_events_date-20200721_1314.tsv
from cpp_bids.
If I do not want to write down all the 1 element variables into extracolumn field, after calling logfile, I can add my variables:
logFile.extraColumns.PE4 = 12;
logFile.extraColumns.LHL24 = 12;
logFile = saveEventsFile('open', expParam, logFile, ...
'segmentNum', 'segmentOnset', 'stepNum', 'stepOnset', 'patternID', ...
'category', 'F0', 'isTask', 'gridIOI', 'patternAmp', **'LHL24 ', 'PE4',** 'minPE4', ...
'rangePE4', 'minLHL24', 'rangeLHL24');
Or I define all the extracolumns and then call saveEventsFile with the following:
logFile.extraColumns.sequenceNum = 1;
logFile.extraColumns.segmentNum = 1;
logFile.extraColumns.stepNum = 1;
....
logFile = saveEventsFile('open', expParam, logFile);
....
saveEventsFile('save', expParam, currSeq);
saveEventsFile('close', expParam, logFile);
** are to highlight that extracolumn with 12 arrays will be also defined in saveEventsFile ('open')
from cpp_bids.
and this output is good for BIDS? session is empty:
sub-001_ses-_task-RhythmCategFT_run-001_events_date-20200721_1314.tsv
this should be fixed in the new PR.
from cpp_bids.
Maybe @Remi-Gau solved this issue in the recent PR. If so Sorry for the repetition!
I have this error:
Scalar structure required for this assignment.
Error in fMRIMainExperiment (line 139)
currSeq.extraColumns = logFile.extraColumns;
It's mostly due to, currSeq
structure is already "made" and contains all the relevant info I want to save. Then opening a cell array probably throws an error?
For nistance previously I had this:
currSeq(1).fileID = logFile.fileID;
instead of
currSeq.fileID = logFile.fileID;
then it was OK. Now with the extraColumns I can try the same trick!
from cpp_bids.
hopefully doing something like this should do the trick.
currSeq(1).extraColumns = logFile(1).extraColumns;
currSeq(1).fileID = logFile(1).fileID;
will try to create a wrapper function CPP_PTB to make that easier.
from cpp_bids.
This works on my side
clear;
outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
%%% set up
expParameters.subjectNb = 1;
expParameters.runNb = 1;
expParameters.task = 'testtask';
expParameters.outputDir = outputDir;
cfg.testingDevice = 'mri';
[cfg, expParameters] = createFilename(cfg, expParameters);
logFile.extraColumns.Speed.length = 1;
logFile.extraColumns.LHL24.length = 12;
logFile.extraColumns.is_Fixation.length = 1;
% create the events file and header
logFile = saveEventsFile('open', expParameters, logFile);
% we get our info from somewhere else
currSeq(1, 1).onset = 2;
currSeq(end, 1).trial_type = 'motion_up';
currSeq(end, 1).duration = 3;
currSeq(end, 1).Speed = 2;
currSeq(end, 1).is_Fixation = true;
currSeq(end, 1).LHL24 = 1:12;
currSeq(2, 1).onset = 6;
currSeq(end, 1).trial_type = 'jazz';
currSeq(end, 1).duration = 2;
currSeq(end, 1).LHL24 = 1:10;
% transfer the relevant info between structure
currSeq(1).extraColumns = logFile(1).extraColumns;
currSeq(1).fileID = logFile(1).fileID;
saveEventsFile('save', expParameters, currSeq);
% close the file
saveEventsFile('close', expParameters, logFile);
from cpp_bids.
yep, makes totally sense :)
from cpp_bids.
just a question, you would add these inputs where?
expParameters.subjectNb = 1;
expParameters.runNb = 1;
expParameters.task = 'testtask';
expParameters.outputDir = outputDir;
from cpp_bids.
yup exactly.
I am reusing code from the unit test for those examples, so this sort of assumes that those values have been "given" either by userInput or by setParameters as Ceren mentioned.
from cpp_bids.
ok, thanks!
from cpp_bids.
Ok, I've been trying to see if many 1-element variables can be saved without defining extraColumns.length = 1
But I guess the following is not possible:
logFile = struct();
% define the extra columns: they will be added to the tsv files in the order the user input them
logFile.extraColumns = {'sequenceNum', 'segmentNum', 'segmentOnset', ...
'stepNum', 'stepOnset', 'patternID', 'segmentCateg', 'F0', 'isTask', ...
'gridIOI', 'patternAmp', 'minPE4', 'rangePE4', 'minLHL24', ...
'rangeLHL24', 'LHL24', 'PE4'};
logFile(1).extraColumns.LHL24.length = 12; % will set 12 columns with names LHL24-01, LHL24-02, ...
logFile(1).extraColumns.PE4.length = 12;
So now I'm doing this in my tiny function, before calling open saveEventsFile:
logFile = struct();
% define the extra columns: they will be added to the tsv files in the order the user input them
logFile.extraColumns = {'sequenceNum', 'segmentNum', 'segmentOnset', ...
'stepNum', 'stepOnset', 'patternID', 'segmentCateg', 'F0', 'isTask', ...
'gridIOI', 'patternAmp', 'minPE4', 'rangePE4', 'minLHL24', ...
'rangeLHL24', 'LHL24', 'PE4'};
% define the extra columns: they will be added to the tsv files in the order the user input them,
% convert the cell of column name into a structure
if iscell(logFile(1).extraColumns)
tmp = struct();
for iExtraColumn = 1:numel(logFile(1).extraColumns)
extraColumnName = logFile(1).extraColumns{iExtraColumn};
tmp.(extraColumnName) = struct('length', 1);
end
logFile(1).extraColumns = tmp;
end
% logFile.extraColumns.sequenceNum.length = 1;
% logFile.extraColumns.segmentOnset.length = 1;
% logFile.extraColumns.stepNum.length = 1;
% logFile.extraColumns.stepOnset.length = 1;
% logFile.extraColumns.patternID.length = 1;
% logFile.extraColumns.segmentCateg.length = 1;
% logFile.extraColumns.F0.length = 1;
% logFile.extraColumns.isTask.length =1;
% logFile.extraColumns.gridIOI.length = 1;
% logFile.extraColumns.patternAmp.length = 1;
% logFile.extraColumns.minPE4.length = 1;
% logFile.extraColumns.rangePE4.length = 1;
% logFile.extraColumns.minLHL24.length = 1;
% logFile.extraColumns.rangeLHL24.length = 1;
logFile(1).extraColumns.LHL24.length = 12; % will set 12 columns with names LHL24-01, LHL24-02, ...
logFile(1).extraColumns.PE4.length = 12;
from cpp_bids.
Let me hack this for you. :-)
from cpp_bids.
Naah, don't spend time on it. It works. Marie Kondo is happy because i use subfunction. (I got tired a bit :))
You can suggest a trick if it comes to your mind.
from cpp_bids.
By hack I meant show you how I would use the current code to do this. 😄
When I open the tsv file I get what I want.
Does it work for you?
clear;
outputDir = fullfile(fileparts(mfilename('fullpath')), '..', 'output');
expParameters.subjectNb = 1;
expParameters.runNb = 1;
expParameters.task = 'testtask';
expParameters.outputDir = outputDir;
cfg.testingDevice = 'mri';
% define the extra columns: they will be added to the tsv files in the order the user input them
logFile.extraColumns = {'Speed', 'is_Fixation'};
[cfg, expParameters] = createFilename(cfg, expParameters);
% dummy call to initialize the logFile variable
logFile = saveEventsFile('open', expParameters, logFile);
% set the real length we really want
logFile.extraColumns.Speed.length = 12;
% actual inititalization
logFile = saveEventsFile('open', expParameters, logFile);
% close the file
saveEventsFile('close', expParameters, logFile);
from cpp_bids.
Related Issues (20)
- failing tests on octave / windows
- adding n/a check for empty cells in logfile
- extra empty header/column in logfile HOT 8
- userInput should return automatically if config already contains the subject and session labels
- use file naming functions from BIDS matlab
- transfer json content creation to bids matlab
- change saveEventsFile into a class with specific methods
- [ENH]: use CITATION.cff
- Make sure the Copyright mention is not on the first line of each file
- [BUG]: printing fmri triggers before experiment starts slow down first trial stimulation
- save config at run time HOT 4
- `convertSourceToRaw` enhancement HOT 2
- Add a way to easily uninitialize
- [ENH] json file for eyetracker output
- change copyright format and update miss hit version
- [MNT] add ci tests for notebooks
- [MNT] fix coverage value reported by codecov
- [ENH] Chenge the default of where to save the output to within the experiment folder
- [BUG] Out of memory error on windows when running the "next" run of the BiMotion experiment HOT 4
- fix doc deploy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpp_bids.