Print

Print


Dear Guillaume

This functionality is exactly what I was looking for, thanks a lot! I can now actually prepare the second level analysis based solely on the information in the BIDS, by using spm_BIDS. Participant is fine with me but it would perhaps be more logical with something like subjectmeta (and sessionmeta if a similar feature was to be implemented at the session level) but I agree that this should be decided by someone who knows BIDS far better than me.


Thanks again!
Torben 

Den 31. jan. 2019 kl. 12.56 skrev Flandin, Guillaume <[log in to unmask]>:

Dear Torben,

To add to Cyril's response, you are right that participants.tsv is read
and stored in the BIDS variable but is not directly available in a
query. At the moment, you would have to do something like this (which I
would look at disapprovingly as the BIDS variable is not meant to be
accessed directly):

 subjects = spm_BIDS(BIDS,'subjects');

 sm = subjects(ismember(BIDS.participants.sex,'male'));
 spm_BIDS(BIDS,'data','sub',sm,'type','T1w')

 s25 = subjects(BIDS.participants.age > 25);
 spm_BIDS(BIDS,'data','sub',s25,'type','T1w')

It also assumes that the order of the subjects is the same between what
is returned by spm_BIDS and what is stored in participants.tsv, which
cannot be guaranteed, so you would need to add extra checks to use the
code above on any dataset.

I tried to implement something similar to what you suggested, see
attachment. With it, you should be able to query for subjects like this:

 subjects = spm_BIDS(BIDS,'subjects','participants',...
   struct('sex','male', 'age',@(x) x > 25));
 spm_BIDS(BIDS,'data','sub',subjects,'type','T1w')

Some extra thoughts should be spent in the syntax to use; 'participants'
feels a bit out of place here. Best would be to align with what pybids
does for a similar query; Chris might tell us more.

Best regards,
Guillaume.


On 30/01/2019 22:04, Torben Lund wrote:
Dear Guillaume and Chris

I am in the process of arranging my data in BIDS for a project where we
wish to share data, in an organised maner, and so far this goes well.
For the data analysis, I would like to be able to make combined queries
using spm_BIDS e.g. get T1w scans from all male subjects from a
particular group.

Following the instructions on https://en.wikibooks.org/wiki/SPM/BIDS I
can get all subjects by typing:
subjects=spm_BIDS(BIDS,'subjects’) 

and their T1w scans by typing:
spm_BIDS(BIDS,'data','type','T1w’)

and T1w scans for the first 5 subjects by typing:
spm_BIDS(BIDS,'data','sub’,subjects(1:5),'type','T1w’)

and so on. In the participants.tsv file I have stored the subjects sex
and group information and I should now like to get a list of files
belonging to a certain patient group and gender. Is is possible to make
such a combined query? As I had no luck I have tried to split the
process into more steps by e.g. getting the male subject first. I have
tried e.g.

spm_BIDS(BIDS,'subjects',’metadata’,’sex’,’male’)

or

spm_BIDS(BIDS,’subjects’,’participants’,’sex’,’male’)

but neither of those works, and looking at the code it does not seem
like this feature is supported. I could solve my problem working
directly on the BIDS structure, but it would be so much nicer if it
could be done with spm_BIDS, is this possible?

Best
Torben




--
Guillaume Flandin, PhD
Wellcome Centre for Human Neuroimaging
UCL Queen Square Institute of Neurology
London WC1N 3BG
<spm_BIDS.m>