Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter modulation only for several conditions, not all #191

Closed
HuberMaria opened this issue Feb 10, 2021 · 8 comments · Fixed by #700 · May be fixed by #721
Closed

Parameter modulation only for several conditions, not all #191

HuberMaria opened this issue Feb 10, 2021 · 8 comments · Fixed by #700 · May be fixed by #721

Comments

@HuberMaria
Copy link

Hi,
My name is Maria Huber and I am working on my medical thesis at the Neuropsychiatry and Neuroimaging Lab at the Technische Universität München.

Is it possible to do parameter modulation only for several and not for all conditions in a glm in pspm? I want to do parameter modulation on 6 of my 9 conditions in one session.

I specified all conditions of that session under 'names' in the condition file and added 'pmod' with the same number of elements as 'names'. However as I don't want to do parameter modulation on the last 3 conditions I inserted dummy files for pmod.param (containing ones) with the same number of elements as the respective event onsets. The resulting design matrix now has all black conditions for the 3 dummy modulated conditions. I am just wondering if I am overlooking something or if this is the only way to do it.

Thanks in advance!

Best,

Maria Huber

@dominikbach
Copy link
Contributor

Hi Maria
you should be able to just specify the pmods for the conditions that you need the for, e.g. define pmod(1) and pmod(5) but not the others. If that does not work please post an example definition of your events.
Hope this helps.
Best
Dominik

@HuberMaria
Copy link
Author

Hi Dominik,
thank you for your fast reply. I tried that and simply left the pmod(1).param as an empty cell. Which resulted in the ERROR message: 'Cell contents reference from a non-cell array object.'.
Attached you will find how my condition files look like. For that subject I want to generate a glm with 4 sessions with each 9 conditions.

Best
Maria

Onsets_01_Se_PrCoPa_SeCo.zip

@dominikbach
Copy link
Contributor

Hi Maria

as you say, you left pmod(k).param as an empty cell, but specified pmod(k).name. The right way to do is to leave pmod(k) empty altogether.
I note that many of your onsets are also empty. The durations are non-empty but they will be ignored.
Best
Dominik

@HuberMaria
Copy link
Author

Hi Dominik,

I might have not explained well enough, why my condition file is looking this way, sorry.
As I understand it when you are creating condition files for a glm with more than one session, each condition file has to have the names of all the conditions of all sessions included in the 'names' variable. And then the onset and durations information is stored at the correct spot in the correct condition file respectively. This is why many onsets are empty, it is not their session in that condition file. That information is stored in another condition file.
So keeping that in mind I created the pmod.name the same way, so that pmod.name and 'names' have the same number of elements. So the information for param and poly is also only stored in the condition file for its own session.
Please correct me if I am wrong.
As you suggested I also tried to not define the pmod(x) that I don't want to include in the analysis and also leave the pmod.name empty for all sessions where it is not their turn. The same ERROR occurred as before.

So this is what my condition files for one glm look like now, for one subject with four sessions, 9 conditions each.
test_no_def_pmod.zip

I also attached what the design matrix then looks like once I implemented the dummy pmods. So you can see what I am trying to do. Only the dummy pmod regressors look weird(all black).

1_in_dummy_files.pdf

Thank you very much for your patience.

Best
Maria

@dominikbach
Copy link
Contributor

Hi Maria

I understand. Of course, your names and onsets definition is correct for the purpose then. And what I wrote previously about the durations is incorrect - they will be used, not ignored. (Although, non-zero durations are not recommended with the current models in PsPM).

Regarding the pmods, the way it should work is that you specify all pmods that you want to use in any of the sessions (i.e. pmod(1)-pmod(6), pmod(10)-pmod(12), etc.

The error seems to occur in the GLM function rather than in the function that processes the timings. To reproduce that, it would be preferable if you could also send a data file, and the code you use to call the function.

As a quick fix, since you use different conditions for different sessions, there is no advantage in having them all in one model. So you could just use different GLMs for different sessions. You just need to be careful in case you are normalising the data - that should be done across sessions, rather than separately for each sessions.

Hope this helps
Dominik

@HuberMaria
Copy link
Author

Hi Dominik,

Yes that helps a lot, thank you! I will use the zero durations as you recommend from now on. I think your option for a quick fix is a good idea, although I am not sure how to normalize the data across sessions, when I am doing different GLMs for different sessions. Is there an option for that in the GUI or would I have to adjust the code?

Attached you will find my glm_maria_job script that contains the batch with my specifications and calls pspm_glm.m. My loop looks a bit weird as I have subjects that miss some sessions, but if you use the 2 as suggested in the loop it should work. Also attached the data files and the condition files for subject 2 that has all 6 sessions.

Also the ERROR message that occurred after using the not defined pmods was different after all:
Index exceeds matrix dimensions.
In file "/Users/mariahuber/Desktop/GLM_first_level/PSPM/pspm_glm.m" (v627), function "pspm_glm" at line 582.
In file "/Users/mariahuber/Desktop/GLM_first_level/PSPM/pspm_cfg/pspm_cfg_run_glm_scr.m" (???), function "pspm_cfg_run_glm_scr" at line 38.

datafiles.zip
conditionfiles.zip
glm_maria_job.zip

Best
Maria

@dominikbach
Copy link
Contributor

Hi Maria

I could reproduce your error, and it occurred when processing pmod(10) in session 2. I think the issue is that not all pmods that will later be used are defined in the first session.

So, while you should not specify the pmods for the conditions that will never have a pmod in any session (e.g. 7-9), you need to specify pmod(10) in the first session already (with empty param).

Does that work at all?

Best
Dominik

@HuberMaria
Copy link
Author

Hi Dominik

Thank you very much! It works indeed! It even works with files in which I don't specify the pmods for all sessions in the first session, but only have the information for the specific session stored at the respective position. But only when I put in empty cells pmod(10).param{1}= [] at the places where the pmods for the other sessions are supposed to go. I guess its just checking if there is the right format 'cell' for the pmod(10) in the first session and then gets the actual information of the condition file that is claimed for session 2?

Ok that really helped a lot! Thanks again. I guess the reason why I thought the information only has to be stored for one sessions' pmod in each condition file was, that that's how it works for onsets and durations.

Best
Maria

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants