LNCD

Table of Contents

  • LNCD Home
  • Administration
  • Notebooks
  • Journal Club Presentations
  • Publications
  • Current Projects
  • Completed Projects
  • Current Grants
  • Datasets by Project
  • Brain ROIs and Measures
  • ️Tools And Methods
  • Big Data
  • RA Homepage
  • Undergrad Resources
  • Recent Changes
  • Maintenance
  • Site Map
  • Random Page
LNCD
Admin » Source Localization

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:source_localization [2026/11/09 16:21] – sdm63tools:source_localization [2026/11/09 16:38] (current) – sdm63
Line 13: Line 13:
     * data: your brain data      * data: your brain data 
       * contains eeg files that you load in        * contains eeg files that you load in 
 +\\
  
 === Brainstorm Scripts === === Brainstorm Scripts ===
   * I have one script for each task epoch (fix, delay, resting state, etc)   * I have one script for each task epoch (fix, delay, resting state, etc)
   * Sets the necessary paths to the freesurfer folders, list of glasser parcellations, merge 7t, and preprocessed data    * Sets the necessary paths to the freesurfer folders, list of glasser parcellations, merge 7t, and preprocessed data 
-  *   * We need the subject folders that have 'long' in the title so it checks for that and if yes, moves on +  * We need the subject folders that have 'long' in the title so it checks for that and if yes, moves on 
 <code> if contains(FSsubfolder,'long') </code> <code> if contains(FSsubfolder,'long') </code>
 + 
   * Define the subject folder (protocol), DBfolder is the brainstorm_db, and then I named it sourceLocal_beamforming_ subjectID based on their MRI date, not eeg date to match the freesurfer file   * Define the subject folder (protocol), DBfolder is the brainstorm_db, and then I named it sourceLocal_beamforming_ subjectID based on their MRI date, not eeg date to match the freesurfer file
-<code> subjectDBfolder = [DBfolder '/sourceLocal_beamforming_' SubjectNameMRI]; </code>+<code> subjectDBfolder = [DBfolder '/sourceLocal_beamforming_' SubjectNameMRI]; </code>  
 + 
 +  * Here we are setting the protocol name 
 +  * The iProtocol bst_get checks to see the protocol already exists in the database 
 +  * If no (iProtocol is empty), then create protocol, and add the subject within it 
 +    * That just creates a blank subject line in the protocol to then fill with the anat and data 
 +  * If the protocol does exist, then load it and set it as the current protocol 
 + 
 +<code>  
 +ProtocolName = sprintf('sourceLocal_beamforming_%s', SubjectNameMRI); 
 +iProtocol = bst_get('Protocol', ProtocolName); 
 + 
 +if isempty(iProtocol) 
 + 
 +    gui_brainstorm('CreateProtocol', ProtocolName, 0, 0); 
 +    db_add_subject(SubjectNameMRI, [], 1); 
 + 
 +else 
 + 
 +    gui_brainstorm('SetCurrentProtocol', iProtocol); 
 + 
 +end  
 + 
 +</code> 
 + 
 + 
 +  * bst_get('ProtocolStudies') pulls out the studies within one protocol  
 +    * A study is like each EEG file you have loaded into that protocol, so everyone should have fix, delays, and rest 
 +  * But this code below checks to see if fix (or delay or rest or whatever what you're running) already exists and removes it (cause maybe you wanna redo it) 
 + 
 +<code> 
 +sStudies = bst_get('ProtocolStudies'); 
 + 
 +for iStudy = 1:length(sStudies.Study) 
 +studyName = sStudies.Study(iStudy).Name; 
 + 
 +    if contains(studyName, 'fix') 
 + 
 +        fprintf('Deleting study: %s\n', studyName); 
 +        db_delete_studies(iStudy); 
 + 
 +    end 
 + 
 +end 
 + 
 +</code> 
 + 
 +  * Find the lunaID 
 +  * Find the MRI date 
 +  * Find the row in merge 7t with the corresponding lunaID and MRI date 
 +  * Using that row, find the EEG date 
 +  * Create the path to the corresponding EEG file 
 + 
 +<code> 
 +luna = str2double(SubjectNameMRI(1:5)); 
 +MRIdate = str2double(SubjectNameMRI(7:14)); 
 +                     
 +rowIdx = merge7t(:,1) == luna & merge7t(:,4) == MRIdate; 
 + 
 +if any(rowIdx) 
 + 
 +   eeg_date = merge7t(rowIdx,5); 
 + 
 +   pattern = sprintf('%s_%s*_rerefwhole_ICA_icapru.set', string(luna), string(eeg_date)); 
 +   files = dir(fullfile(EEGfolder, pattern)); 
 + 
 +   EEGpath = fullfile(EEGfolder, files.name); 
 + 
 +else 
 + 
 +   continue 
 + 
 +end 
 +</code>