Script to import channel file without data

Hi Brainstorm team!

I have been working on the creation of the forward model for my research. I did all the tutorials and everything is working perfectly from the GUI. As I only want to create the forward model, I have not been working with data and I'm assuming a case with no recordings associated.
From the GUI, I imported my imaging and I'm able to import an ASCII Name_XYZ file to enter the channel`s description and continue with the creation of the head model. Now, I'm trying to automate all the process so I'm creating the script myself (as script generation does not allow to create protocols/subjects or import channel file). However, I have been having problems to import my channel file without data since the main function to do this import_channel.m (called from process_import_channel) asks for a study ID (iStudy) or to have the SCS coordinates:

% If the SCS coordinates are not defined (NAS/LPA/RPA fiducials), try to use the MRI=>subject transformation available in the MRI (eg. NIfTI sform/qform)
% Only available if there is one study in output

There is a way to import the channel file without data and SCS coordinates from script?
Thank you so much,

Valentina

SCS coordinates are mandatory, this is the central coordinates system in Brainstorm, anatomical surfaces and sensor positions are defined in the system of coordinates.
Therefore you need to define NAS/LPA/RPA.
To use default positions: simply compute the MNI transformation for the MRI of your subject (process "Import > Import anatomy > Compute MNI transformation")

Subjects are created automatically by the processes when importing the anatomy.
"Study" folders are created automatically when importing data to the database. If you don't import data, you need to create a folder manually with db_add_condition.m. This will give you the iStudy you need.
(look for examples in the code)

https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Reference:_File_manipulation

Hi Francois, thank you so much for your answer.
I have been trying with the db_add_condition but still without success. I took a look at the tutorial scripts when they use it but actually they are creating a simulated data that allows then to import the channels. However, I'm trying to import the channel file without any data.

With db_add_condition I already created an empty study but I'm having problems on the input to process_import_channel as it demands a first argument. In the script examples this input is the structure of the data matrix. Do you know what can I insert there ? (I have tried with the protocol info and study info but without success).

Here is my code if it helps:

% Process: Import channel file
% Create a study/condition folder
conditionName = 'simulate';
iStudySim = db_add_condition(subjectName, conditionName);
studyStruct = bst_get('Study', iStudySim);

protocolStruct = bst_get('ProtocolInfo');

bst_process('CallProcess', 'process_import_channel', studyStruct, [], ...
'channelfile', {channelFile, 'ASCII_NXYZ'}, ...
'usedefault', 1, ...
'channelalign', 1,...
'subjectname', subjectName);

Thank you so much,

Valentina

Indeed, without an input file, you need to call directly import_channel.m, not the process version.

It worked! Thank you so much :smiley: