sccn / amica

Code for AMICA: Adaptive Mixture ICA with shared components
BSD 2-Clause "Simplified" License
23 stars 13 forks source link

Running a for loop with an ICA/AMICA without a window for each participant #39

Open p1050666 opened 1 year ago

p1050666 commented 1 year ago

I'm trying to create a for loop allowing me to run an AMICA for every participant on EEGLab using Matlab. Here's the script. On each participant, I have to click "OK" on a window and I'd like instead to let the program run everything. Is there a way to simply run an AMICA for each participant without having to press "OK" ? I thought setting the EEG.etc.auto_ok to 2 would have worked but it doesn't seem to be the case. Thanks !

`for s=1:nsubj

    fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});

    % Path to the folder containing the current subject's data
    data_path  = [home_path subject_list{s} '/'];

    sname      = [data_path subject_list{s} '.set'];

    if exist(sname, 'file')<=0
            fprintf('\n *** WARNING: %s does not exist *** \n', sname);
            fprintf('\n *** Skip all processing for this subject *** \n\n');

    else
        EEG = pop_loadset('filename', [subject_list{s} '.set'], 'filepath', data_path);
        EEG = pop_runamica(EEG);
        EEG.etc.auto_ok = 2;
        EEG.setname = [EEG.setname '_amicadone'];
        EEG = pop_saveset(EEG, 'filename', [EEG.setname '.set'], 'filepath', data_path)

    end    
 end

`

japalmer29 commented 1 year ago

You can use the runamica15.m, followed by eeg_loadamica.m with the output directory to load the output and then save the dataset in the loop.


From: p1050666 @.> Sent: Friday, February 24, 2023 8:20:33 PM To: sccn/amica @.> Cc: Subscribed @.***> Subject: [sccn/amica] Running a for loop with an ICA/AMICA without a window for each participant (Issue #39)

I'm trying to create a for loop allowing me to run an AMICA for every participant on EEGLab using Matlab. Here's the script. On each participant, I have to click "OK" on a window and I'd like instead to let the program run everything. Is there a way to simply run an AMICA for each participant without having to press "OK" ? I thought setting the EEG.etc.auto_ok to 2 would have worked but it doesn't seem to be the case. Thanks !

`for s=1:nsubj

fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});

% Path to the folder containing the current subject's data
data_path  = [home_path subject_list{s} '/'];

sname      = [data_path subject_list{s} '.set'];

if exist(sname, 'file')<=0
        fprintf('\n *** WARNING: %s does not exist *** \n', sname);
        fprintf('\n *** Skip all processing for this subject *** \n\n');

else
    EEG = pop_loadset('filename', [subject_list{s} '.set'], 'filepath', data_path);
    EEG = pop_runamica(EEG);
    EEG.etc.auto_ok = 2;
    EEG.setname = [EEG.setname '_amicadone'];
    EEG = pop_saveset(EEG, 'filename', [EEG.setname '.set'], 'filepath', data_path)

end

end

`

— Reply to this email directly, view it on GitHubhttps://github.com/sccn/amica/issues/39, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACRBESVLY6NJDCXNBQQCQ7LWZFM6DANCNFSM6AAAAAAVHQSLQQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

p1050666 commented 1 year ago

Hi and thanks for the reply ! When I try running the runamica15 function, Matlab doesn't seem to recognize it. Can you enlighten me please ?

japalmer29 commented 1 year ago

Install eeglab and then the amica1.6 plugin from file -> manage extensions.

Or download files from github and add to path.

Need to make sure the amica files are in the Matlab path.


From: p1050666 @.> Sent: Friday, February 24, 2023 8:49:39 PM To: sccn/amica @.> Cc: Jason Palmer @.>; Comment @.> Subject: Re: [sccn/amica] Running a for loop with an ICA/AMICA without a window for each participant (Issue #39)

Hi and thanks for the reply ! When I try running the runamica15 function, Matlab doesn't seem to recognize it. Can you enlighten me please ?

— Reply to this email directly, view it on GitHubhttps://github.com/sccn/amica/issues/39#issuecomment-1444897733, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACRBESRMRBACH4QWG7AOVCTWZFQLHANCNFSM6AAAAAAVHQSLQQ. You are receiving this because you commented.Message ID: @.***>

p1050666 commented 1 year ago

Hello and thank you for the reply ! When I try running the function, I constantly have issues regarding the dependency with MPICH2. Each time I'm using the function, I have to repair the MPICH2 tool and the script ends up with this message error: "Unrecognized field name "W". Is there a way to fix that ? I don't see a parameter in this function allowing me to manage that. Thank you !

japalmer29 commented 1 year ago

If you were able to run it before, then maybe try to replace the binary in the new amica location with the old binary. The latest version that should be in the latest amica eeglab plug-in folder is based on Intel oneapi not mpich2.


From: p1050666 @.> Sent: Friday, February 24, 2023 9:47:29 PM To: sccn/amica @.> Cc: Jason Palmer @.>; Comment @.> Subject: Re: [sccn/amica] Running a for loop with an ICA/AMICA without a window for each participant (Issue #39)

Hello and thank you for the reply ! When I try running the function, I constantly have issues regarding the dependency with MPICH2. Each time I'm using the function, I have to repair the MPICH2 tool and the script ends up with this message error: "Unrecognized field name "W". Is there a way to fix that ? I don't see a parameter in this function allowing me to manage that. Thank you !

— Reply to this email directly, view it on GitHubhttps://github.com/sccn/amica/issues/39#issuecomment-1444964147, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACRBESTXD4CW3J7SAF6JGADWZFXEDANCNFSM6AAAAAAVHQSLQQ. You are receiving this because you commented.Message ID: @.***>

p1050666 commented 1 year ago

Thank you ! Last question I promise. I still have an error:

"Error: files must precede num_samples in paramfile Something went wrong... No gm present, setting num_models to 1 No W present, exiting Unrecognized field name "W" error message "

Here's the script:

'

for s=1:nsubj

    fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});

    % Path to the folder containing the current subject's data
    data_path  = [home_path subject_list{s} '/'];

    sname      = [data_path subject_list{s} '.set'];

    if exist(sname, 'file')<=0
            fprintf('\n *** WARNING: %s does not exist *** \n', sname);
            fprintf('\n *** Skip all processing for this subject *** \n\n');

    else
        EEG = pop_loadset('filename', [subject_list{s} '.set'], 'filepath', data_path);
        EEG = runamica15(EEG);
        EEG = eeg_loadamica('outdir', data_path);
        EEG.etc.auto_ok = 2;
        EEG.setname = [EEG.setname '_amicadone'];
        EEG = pop_saveset(EEG, 'filename', [EEG.setname '.set'], 'filepath', data_path)

    end    
 end   

'

japalmer29 commented 1 year ago

This is the error message that comes up when the binary crashes. To verify that the binary is working you can use the command line as described at sccn.ucsd.edu/~jason/amica_web.html.


From: p1050666 @.> Sent: Friday, February 24, 2023 10:38:39 PM To: sccn/amica @.> Cc: Jason Palmer @.>; Comment @.> Subject: Re: [sccn/amica] Running a for loop with an ICA/AMICA without a window for each participant (Issue #39)

Thank you ! Last question I promise. I still have the "Unrecognized field name "W" error message ? Here's the script:

'for s=1:nsubj

fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});

% Path to the folder containing the current subject's data
data_path  = [home_path subject_list{s} '/'];

sname      = [data_path subject_list{s} '.set'];

if exist(sname, 'file')<=0
        fprintf('\n *** WARNING: %s does not exist *** \n', sname);
        fprintf('\n *** Skip all processing for this subject *** \n\n');

else
    EEG = pop_loadset('filename', [subject_list{s} '.set'], 'filepath', data_path);
    EEG = runamica15(EEG);
    EEG = eeg_loadamica('outdir', data_path);
    EEG.etc.auto_ok = 2;
    EEG.setname = [EEG.setname '_amicadone'];
    EEG = pop_saveset(EEG, 'filename', [EEG.setname '.set'], 'filepath', data_path)

end

end

'

— Reply to this email directly, view it on GitHubhttps://github.com/sccn/amica/issues/39#issuecomment-1444976164, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACRBESUDYMJLWF3Q7TPCUFLWZF5D7ANCNFSM6AAAAAAVHQSLQQ. You are receiving this because you commented.Message ID: @.***>

japalmer29 commented 1 year ago

If you updated amica in eeglab and now get the error message, look for a previous amica folder in eeglab plug-ins directory that contains the binary that was working before.


From: Jason Palmer @.> Sent: Friday, February 24, 2023 10:42:45 PM To: sccn/amica @.>; sccn/amica @.> Cc: Comment @.> Subject: Re: [sccn/amica] Running a for loop with an ICA/AMICA without a window for each participant (Issue #39)

This is the error message that comes up when the binary crashes. To verify that the binary is working you can use the command line as described at sccn.ucsd.edu/~jason/amica_web.html.


From: p1050666 @.> Sent: Friday, February 24, 2023 10:38:39 PM To: sccn/amica @.> Cc: Jason Palmer @.>; Comment @.> Subject: Re: [sccn/amica] Running a for loop with an ICA/AMICA without a window for each participant (Issue #39)

Thank you ! Last question I promise. I still have the "Unrecognized field name "W" error message ? Here's the script:

'for s=1:nsubj

fprintf('\n******\nProcessing subject %s\n******\n\n', subject_list{s});

% Path to the folder containing the current subject's data
data_path  = [home_path subject_list{s} '/'];

sname      = [data_path subject_list{s} '.set'];

if exist(sname, 'file')<=0
        fprintf('\n *** WARNING: %s does not exist *** \n', sname);
        fprintf('\n *** Skip all processing for this subject *** \n\n');

else
    EEG = pop_loadset('filename', [subject_list{s} '.set'], 'filepath', data_path);
    EEG = runamica15(EEG);
    EEG = eeg_loadamica('outdir', data_path);
    EEG.etc.auto_ok = 2;
    EEG.setname = [EEG.setname '_amicadone'];
    EEG = pop_saveset(EEG, 'filename', [EEG.setname '.set'], 'filepath', data_path)

end

end

'

— Reply to this email directly, view it on GitHubhttps://github.com/sccn/amica/issues/39#issuecomment-1444976164, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACRBESUDYMJLWF3Q7TPCUFLWZF5D7ANCNFSM6AAAAAAVHQSLQQ. You are receiving this because you commented.Message ID: @.***>