How to calculate the contrast between two different groups based on GLM?

I am working with the BIDS data format for nirx group analysis. I apologize for my English.I would like to know if it is possible to calculate the contrast for two different groups of the same experiment? I have two different groups (Those who do well in math and those who do poorly) they are undergoing one experiment. But how do I get visual information about the contrast and differences of these two groups?
I want to get something like that.The photo shows information about the contrast between different events in the same group. But as I wrote above, I need to get a contrast between two different groups (preferably both for the same events and for different ones). I use the GLM model. Unfortunately, I have not found information on how to calculate the contrast between two different groups in one study. Please help me in any way you can
Capture

The conversation from How to display the visual difference between two groups using GLM? · Issue #3325 · nilearn/nilearn · GitHub should continue here.

You can follow the unpaired t-test example at Nilearn: Statistical Analysis for NeuroImaging in Python — Machine learning for NeuroImaging. I believe that the caveat you mentioned in the Nilearn GitHub issue does not apply to the analysis you are trying to do.

I am not very familiar with fNIRS, so there may be additional considerations you need to take into account, but the example should work fine for fMRI data.

@Jens_Colt as @bthirion and @tsalo said you can first try to adapt that example to your data and let us know if you have any trouble at amy particular step.

It is unnecessary to open other questions for this topic on this platform. Let’s please keep the discussion here.

@tsalo
I am very grateful for your answers, it’s late at night, but tomorrow I will try to implement this example. Sorry, I’d like to know if I understand correctly that the input data (sample_vertical and sample horizontal) is this a second-level design matrix? If this is not the case, then what is sample_vertical, sample horizontal in the example above?

I’m sorry, this question is so important to me. My input parameters are design_matrix with information on several subjects, but where do I get data[cmap]? That this is just a topographical distribution of events, do I understand correctly?

No, get data[cmap] are the individual maps that are collected from all the subjects.
For instance, you may have one or two maps per subject that you want to input to the second-level analysis. If you have n subjects, this majes n or 2*n brain maps.
Once you have these maps, you have to specify the design patrix, that shoudl comprise one row per image and one column per effect you want to take into account (subject age, group etc.)
Does that make sense ?
Best,

Can you tell me how can I get such a card for the subject? I have two groups of 25 people. In order for me to calculate the contrast and perform an unpaired test between groups Do I need to get cards first? But how do you get them? Are there any ready-made solutions for nirs data in the mne or nilearn libraries. I’m sorry, I’m a newbie, but this task is very important for me, I apologize for stupid questions …

The question is: what data do you have per subject ? To run a second-level analysis, you first need to have run a first-level analysis, that extracts meaningful statistics from the individual data, and perform group-level comparison. these meaningful individual statistics typically boil down to one or two brain maps for individuals.

If you’re using fMRI, you probably want to take a look at
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjdxv-hja_5AhVNXxoKHZgDAnEQFnoECBoQAQ&url=https%3A%2F%2Fwww.cs.mtsu.edu%2F~xy2e%2FfMRIHandBook.pdf&usg=AOvVaw3CpIWMr2j-hipZ-SvoIwLg

Note that if you’re using EEG or MEG data, you should look at MNE not Nilearn.

Best,

I am working with fNIRS data. I can run a single analysis for each subject based on the GLM model. But second_model_level takes two arguments as inputs: the first is the design matrix (and there are no questions here) the second is the second_level input, which consists of sample_vertical[‘cmaps’] + sample_horizontal[‘cmaps’] and I can’t understand what information I need from my subject data needs to be saved to be passed as the second_input argument. Could you tell me what cmaps means. What information do I need to transfer besides the design matrix. Sorry for my annoying

I have a contrast map for different events within the same group. As I said before, I want to do the same but for different groups. Accordingly, can I use the contrast map within the group for different events as an input parameter for the second level model? How can I approach the calculation of the contrast between groups - maybe I don’t understand the sequence, I’m sorry, I’m not a native English speaker

Yes, ‘cmaps’ is a shortcut for ‘contrast maps’, which means that a second-level analysis needs a bunch of contrast maps that result from first-level analysis.
So what you need to provide is a list of paths pointing to these files, ordered as they are in the design matrix.
Home it makes sense,
Bertrand