Global Local

ecog_preprocessing (Mat) → makeTrials_GL (Mat) → BIDS_coding (WSL)

Step 1: Download data files (Box)

  1. Go to Box → ECoG_Task_Data → Cogan_Task_Data and locate the Subject (D#) folder → Global Local task folder → All blocks subfolder

  2. Download all Box data files from “All Blocks” folder

  3. Then Copy + Paste files into Local PC folder in CoganLabNLInUnit PreprocessingSubject (D#) → Global Local → All blocks

  4. KEY: locate the Excel csv file titled: GL_MainTask_Data_D#_taskdate

  5. RENAME this file to Trials

  6. EDF file: 2 options - Download (local PC) or Box Drive (no download)

    1. Download : from TaskUploadDir Box → TaskUploadDir → Download → move to same local PC Global Local folder (Only if you want to download!)

    2. Box Drive : No download, will use Box Drive path in edf_filename variable instead of local PC path → See Step 2!

Step 2: ecog_preprocessing(Matlab)

general preprocessing script

  1. Once your files are downloaded and Trials is renamed, open Matlab and run the ecog_preprocessing script (used for all tasks preprocessing)

  2. Start the same as all other tasks → create a new Case for the task (Global Local = 009 )

  3. Fill in all of the case variable information accordingly: see differences!

    1. KEY 1 - for Global Local only, the ptb_trialInfo is commented out! → put a % (percentage sign) in front! This is because we do not need to get trialInfo – it is replaced by the Trials excel sheet we renamed in Step 1.

    2. KEY 2 - edf_filename variable (path) will change depending on if you downloaded the EDF above from Box, or if you are uploading it directly from Box Drive:

      1. Downloaded EDF path to InUnit Preprocessing (PC): C:\Users\ncl24\Desktop\CoganLabNL\InUnit Preprocessing\D81\Lexical Delay\D# DATE COGAN_TASKNAME.EDF

      2. Box Drive EDF path to TaskUploadDir (Box): C:\Users\ncl24\Box\CoganLab\ECoG_Task_Data\TaskUploadDir\D# DATE COGAN_TASKNAME.EDF

  4. Once all variables are filled out, highlight + run (F9) to load into your workspace

  5. Ignore the trialInfo section (don’t need trialInfo) → Go straight to the edfread + labels section & run!

  6. This will read the EDF file to create your labels variable

  7. Then, run the following extract trigger + mic channel section

  8. This will create your trigger & mic variables, as well as save them as trigger.mat & mic.mat files in your task folder.

  9. Finally, run the .ieeg.dat + experiment file section, that will save the experiment.mat & .ieeg.dat files in your task folder

  10. As well as create the folders mat & taskdate (e.g.**230807*)*

    1. Move the experiment file into the mat folder

    2. At the end of Step 5, the Trials.mat file will automatically save under the taskdate (230807) → mat folder on Box!

Step 3: MaketrigTimes (Matlab)

trigTimes + trigTimes_audioAligned files

  1. When you reach the maketrigtimes section, you will open the maketrigtimes.m script and run it in a separate window next to ecog_preprocessing.

  2. In order to run maketrigtimes successfully, you will need to have:

    1. The trigger variable already loaded in your workspace

      • Should already be there if going straight from running ecog_preprocessing – but if not, double-click on trigger saved in folder

    2. Already run edfread_fast

      • If not, go back and run this in ecog_preprocessing & make sure that your edf_filename variable (path to EDF) from the case variables is loaded in your workspace before doing so.

  3. Run the first section at the top to load the graph of the triggers

    • Uncomment the -triggers (negative) linefor Global Local!

      • Otherwise the graph will appear upside down

  4. Then, proceed as usual and make the trigTimes adjustments you do for all other tasks

    1. Global Local-specific Task Info :

      1. Total # triggers → trigTimes = 448

      2. 4 blocks total, 112 triggers per block

        1. Rare cases could have 512 total trigs, 128 per block

      3. Seconds between triggers = 1.5

      4. Threshold (thresh) = -1.25

        1. Bc graph is inverted / negative from the -triggers line!

    2. If you need to delete excess triggers (first, last, random in middle) run: trigTimes([1,2,3,etc.]) = []

      • Fill in brackets with which specific trigger numbers you need to delete!

    3. Once trigTimes = 448, run the final section to save trigTimes.mat file to your PC folder!

  5. Finally, return to the ecog_preprocessing script tab and run the section below, to align the audio to your saved trigTimes

    • This will create the trigTimes_audioAligned.mat file and save it into your PC folder

Step 4: Upload Files + Copy EDF to Box D_Data

  1. Before moving on! → Upload all files to BoxD_Data from InUnit Preprocessing folder: Box → D_Data → Global Local → Subject (D#)

    1. Critical because the makeTrials_GL script pulls and uses files from Box only! (D_Data Global Local folder specifically)

      • So before running that script, all files must be uploaded there in order for it to work

    2. Upload the files to D_Data in the exact same way as all other tasks! - only difference = Trials.csv instead of trialInfo

  2. Also! → Copy EDF file into D_Data folder from TaskUploadDir

    1. The edfread command in this program can only read EDFs / files from the D_Data folder!!!

    2. So you must Copy the EDF from TaskUploadDir into the D_Data folder with the rest of the uploaded files!

    3. SEE BELOW - you must also change Path to EDF!!!

      • Of edf_filename variable + edfread_fast(edf_filename) commands!

Step 5: makeTrials_GL (Matlab)

Global Local only script to make Trials.mat

  1. Once all files have been uploaded to Box → D_Data folder, return to Matlab and run the makeTrials_GL.m script in another separate tab window → this script will output the final Trials.mat file when finished!

  2. STEPS TO RUN SUCCESSFULLY (also written on script!)

    • Step 1 : Copy EDF file into D_Data Box folder! (from TaskUploadDir)

      • KEY - Make sure EDF file is copied into the D_Data Subject Global Local folder on Box!

    • Step 2: Edit info (specific to each subject) + copy in command line to run each command below (A, B, C) ONE AT A TIME:

      • 2A) Command 1: change edf_filename variable

        edf_filename = ‘C:\Users\ncl24\Box\CoganLab\D_Data\GlobalLocal\D103\240110 COGAN_GLOBALLOCAL.EDF’;

      • 2B) Command 2: change h variable

        h = edfread_fast(‘C:\Users\ncl24\Box\CoganLab\D_Data\GlobalLocal\D103\240110 COGAN_GLOBALLOCAL.EDF’);

      • 2C) Command 3: run makeTrials_GL function

        makeTrials_GL(‘D103’, ‘240110’)

        1. Must replace: (‘subject’, ‘taskdate’)

          1. Replace subject with ‘D#’

          2. Replace date with ‘taskdate’ (e.g. ‘230807’)

        2. Final format: makeTrials_GL(‘D#’, ‘taskdate’)

          1. Example : D94

            1. subject = ‘D94’

            2. date = ‘230807’

            3. makeTrials_GL(‘D94’, ‘230807’)

        3. You MUST add the single ‘quotations’ around each of the real variables that you enter, in order for them to be registered as the values for those variables!

      • Once 2C is finished running, you are done!

    • Final output = Trials.mat (when 2C is done ^)

      1. Trials.mat file will automatically save under the taskdate (e.g. 230807) → matfolder on Box

      2. Example path to locate Trials.mat file:

      • Box -> CoganLab -> D_Data -> GlobalLocal -> D103 (subj) -> 240110(taskdate) -> mat -> Trials.mat

    • If you would like to save it in your local PC folder (InUnit Preprocessing) as well, you can download the file from Box and copy it there! – you don’t have to though.

Step 6: BIDS_coding (WSL → Visual Studio (VS) Code program)

BIDS

  1. Open WSL

  2. Open BIDS_coding workspace (folder from Desktop)

    • File (top left) → Open Folder → Desktop → BIDS_coding

      1. Make sure it opens into BIDS_convert_wsl.sh script!

      2. BIDS_coding → BIDS_converter → BIDS_convert_wsl.sh

      3. C:/Users/ncl24/BIDS_coding/BIDS_converter/BIDS_convert_wsl.sh

  3. In “Terminal” (command window at bottom), type git pull

    • Make sure you are in the right workspace, should look like this:

      1. image4

      2. Press Enter

  4. If you encounter an error message!

    1. Message: image8

    2. You will need to make sure all of your changes to ALL scripts in the workspace (modified files will have an “M” next to them in explorer left side bar) have been COMMITTED to Github before running the next line, because they will be ERASED!!!

      • To commit changes to github: type git pushgit commit

    3. If your only changes are the variables of subject, task, etc. that you make for specific subjects, then you don’t have to commit them – BUT , make sure any files you have run for previous subjects with the script are SAVED TO BOX BEFORE RUNNING the next command, because they will be overwritten!!!

      • To Save to Box:

        • Drag sub-D00XX folder into share folder above Workspace in WSL explorer → should be in Share folder on Desktop, then copy into Box → BIDS-1.1_GlobalLocal folder

  5. Once all previous subject files have been saved to Box BIDS Global Local folder, you will reset the script!

    1. Type git reset --hard + Enter!

    2. Should look like this when idone:

      image2

  6. When git reset is done, re-type git pull + Enter!

  7. KEYEdits to make to Script after Reset :

    1. Editing BIDS_convert_wsl.sh script!

    2. EDITS : CRITICAL TO CHANGE THESE IN SCRIPT BEFORE RUNNING!

      1. Line 4 : Change task to → TASKS=(“GlobalLocal”)

        1. Must change from “SentenceRep” default to GlobalLocal (or any task going forward)

          • Use the exact same name as the D_Data folder!

        2. Final : image1

      2. Line 16 : Comment out (#) whole mapfile line!

        1. Don’t need for Global Local (will cause error)

        2. Final : see full line on script image0

      3. Line 17 : Change SUB_IDS=(D#) D# to correct Subject D#’s!

        1. Can run multiple subjects at once , or just one

        2. If running multiple, separate by spaces only! No comma! → see example below:

        3. Final : image5

      4. Line 35 : Comment out (#) the whole line 35!

        1. Global Local doesn’t have task stimuli, so don’t need this line and it will cause an error if you keep it!

        2. Final : see full line on script image6

        3. Only comment this out for Global Local or tasks that don’t have

          task stimuli!

          • For other future tasks that do, change the “sentence_rep” task

            name in the middle of the command line (35) and insert the correct task name to use proper task stimuli!

    3. CTRL + S TO SAVE ALL EDITS TO SCRIPT!!!

  8. When all edits have been made to script & saved ( ctrl + s ), type conda activate BIDS_coding + Enter!

  9. The conda activate command will change (base) at the start of the command path to (BIDS_coding)

    • Once the new command line pops up below:

      • Type cd BIDS_converter + Enter!

  10. within BIDS_coding (adds it to end of path), which is where you can now run the script to perform the BIDS conversion functions

    • Once the next command line pops up below with /BIDS_converter at the end: type ./BIDS_convert_wsl.sh + Enter!

STEPS 8, 9, 10 SHOULD LOOK LIKE THIS : (in order top → bottom!)

image7

  1. The script should then run for a few minutes (10-15 min) after entering the last command to create all of the converted BIDS files!

    1. Final output will be on the left side bar (WSL Explorer)

      • To open explorer: click double paper icon at top left corner

    2. Under ncl24 → Workspace → GlobalLocal → BIDS

      • Locate the sub-D0XXX folder!

        1. i.e. sub-D0100 for Subject D100

        2. image9

          • This is where all of the finalized BIDS files will go!

  2. Last step: move to share folder (on WSL)

    • When it is finished creating BIDS files, in the left side bar with workspaces, drag and drop this sub-D00XX output folder containing the BIDS files into the ” share” folder above Workspace! (see top of pic above) 1. Then you will be able to access it from Share PC folder on Desktop! → if not moved to share, can’t access on Windows

Final Step: Upload sub-D00XX on Share folder to Box BIDS-1.1_GlobalLocal

  • Copy sub-D00XX with all finalized BIDS file outputs from Share PCfolder into Box → CoganLab → BIDS-1.1_GlobalLocal → BIDS folder!

image3