Skip to content

MUSC Reconstruction

Shared with the CNT

This procedure runs on infrastructure the lab and the CNT operate together. The CNT manual keeps its own copy; changes to the shared steps are agreed with the CNT.

Flagged for merging

The October 2026 audit recommends merging this page with a sibling (see AUDIT.md). The content stands until then.

What this page tells you

Reconstruction SOP for MUSC patients: create a REDCap record in the MUSC DAG, download dicoms from the Penn_MUSC_R01 Box folder, convert with MRIcroGL (SAG T1 MPRAGE PRE, AX BONE), label electrodes in voxtool, run run_musc_recons.py on Borel, upload to Box, email the MUSC coordinator and the MUSC PI.

PART I: PRE-IMPLANT:

  • Create redcap ID for the MUSC patient:
    • At the top, make sure you are in no assignment
    • Create record
    • REDCap gives an RID ###. Enter the MUSC ID in both the “last name” and “first name” fields
    • Check MUSC for institution and put Epilepsy Patient
    • Make sure to assign the record to the MUSC Data Access Group in REDCap
  • Export the correct images:
    • In Penn Box go to: Penn_MUSC_R01 → MUSC_Subject_Data → MUSC_Epilepsy_Patient Data → SEEG_Implant_Reconstruction → 3T subject ID folder
    • Within the subject ID folder, download (one at a time) the DICOMs in:
      • Pre_MRI folder
      • Implant_CT folder
    • Once downloaded:
      • Double-click the file. A new folder will appear. Rename this folder to either Post-CT or Pre-MRI so you can keep track of which is which.
  • Convert the MRI dicom to nifti in MRIcroGL:
    • Open MRIcroGL on your laptop
    • Select Import in the top left
    • Select Convert DICOM to NIfTI
    • Select Reset Defaults
    • In Output Filename, leave what is there already: %f_%p_%t_%s
    • For Output Directory put your Desktop
    • For Output Format leave it as Compressed NIfTI (.nii.gz)
    • Example:
      dcm2niix General settings (duplicate)
    • In Select Folder to Convert… drag and drop or select the entire downloaded Pre-MRI DICOM folder into the space that says “Drop files/folders to convert here”
    • This converts the entire 3T MRI to NIfTIs, but only one sequence is needed
      • For the pre-implant MRI use the: SAG TI MPRAGE 1MM 3D VOL PRE_MPR_Tra
        • In these sequence names, sagittal is the default orientation, cor means coronal, and tra means transverse (axial)
    • Select this sequence and rename it to: sub-RID####_ses-clinical01_acq-3D_space-T00mri_T1w.nii.gz
  • Convert the CT dicom to nifti in MRIcroGL:
    • Open MRIcroGL on your laptop
    • Select Import in the top left
    • Select Convert DICOM to NIfTI
    • Select Reset Defaults
    • In Output Filename, leave what is there already: %f_%p_%t_%s
    • For Output Directory put your Desktop
    • For Output Format leave it as Compressed NIfTI (.nii.gz)
    • Example:
      dcm2niix General settings with example filename myFolder_MPRAGE_19770703150928
    • In Select Folder to Convert… drag and drop or select the entire downloaded Post-CT DICOM folder into the space that says “Drop files/folders to convert here”
    • This converts the entire post-implant CT to NIfTIs, but only one sequence is needed:
      • For the post-implant CT use: AX BONE or Brain_Lab_Bone
    • Select this sequence and rename it to: sub-RIDXXXX_ses-clinical01_acq-3D_space-T01ct_ct.nii.gz
  • Now that the converted niftis are made, put the niftis in the sub-RIDXXXX/ses-clinical01 folder on your Desktop:

    • Put the MRI NIfTI in the folder called anat
    • Put the CT NIfTI in the folder called ct
    • Once you label the electrodes, the electrode coordinates will go in the folder called ieeg
    • Parent folder: sub-RID####
      BIDS folder tree for sub-RID0981 (duplicate)
      • Sub-folder: ses-clinical01
        * anat
        * sub-RID####_ses-clinical01_acq-3D_space-T00mri_T1w.nii.gz
        * ct
        * sub-RID####_ses-clinical01_acq-3D_space-T01ct_ct.nii.gz
        * ieeg
        * sub-RID####_ses-clinical01_space-T01ct_desc-vox_electrodes.txt
  • Once you have this set up, you can delete the DICOMs and the rest of the NIfTIs from your Desktop

PART II: Electrode Labeling

  • Completing this process requires both the post-implant bone CT and the iEEG map created by the clinic
  • Go to your terminal to open voxtool:
    • Type:
      • conda activate voxtool_2
    • Followed by:
      • voxtool
  • Load in the post-implant CT NIfTI using the “Load Scan” tab in the lower left corner of the application
    • Select the post-implant CT NIfTI that you just made
    • The CT image should appear within the black space
      • Check for display abnormalities: compressed CT, incorrect orientation of superior/inferior, anterior/posterior, and right/left.
        • If the CT image has high impedance, you can adjust the threshold from the original 99.96 to a more suitable threshold (for example 99.94 or 99.98)
          • When saving the completed electrode labels, the threshold MUST be returned to 99.96. Pre-save the coordinates at your labeled threshold to fill in any blanks if they get erased when returning to the original 99.96voxTool empty CT viewer (duplicate)
  • Define leads as specified by the clinic map

    • Click “Define Leads” on the lower left section of the application and a pop-up will appear
      • Select the lead “Type”: unless MUSC specifies otherwise, select Depth electrodes
      • “Lead name” is listed in the implant map as an abbreviation. Dimensions is the number of contacts per implanted electrode
        Text<br/>Description automatically generated with medium confidence
      • The X coordinate is the point closest to the center of the brain and should always be 1
      • The Y coordinate is the point closest to the skull and should be the maximum number of contacts within that electrode
      • After each lead name and dimension is entered, you must select Submit or this parameter will not be saved
      • You can check whether each lead has been entered with the correct number of electrodes in the display area under the Submit tab.
      • When this process is done, click Confirm
    • Begin labeling by selecting the label name from the drop-down menu
    • Click on the contact of the corresponding electrode on the CT that is closest to the center of the brain and click Submit. This will automatically be label 1.
      • The next label in the “Label” column and the Y coordinate in the “Lead” column will now change to 2, meaning the 2nd contact of that electrode.
      • Change the label and Y coordinate to 12 to denote that you are labeling the last contact, the one closest to the skull. (In this example the last point is the 12th contact. If the total number of contacts is different, change these labels to that number.)
      • Count the remaining contacts of the electrode, select the final contact point, then click Submit
      • When the first and last contacts have been labeled, click “Interpolate” to auto-calculate the coordinates of the remaining contacts
        • If a label does not interpolate, the electrode may be curved and will need to be labeled manually
          • Find the contact number by counting from the point closest to the center of the brain (point 1) up to the unlabeled contact
          • Enter the number of the unlabeled contact in the “Label:” row and again in the “Y:” coordinate space
          • Select that contact, then select “submit”
    • To save the completed labeling, select “Save as…”
      • Change the file name to sub-RID####_ses-clinical01_space-T01ct_desc-vox_electrodesvoxTool with labeled contacts (duplicate)
  • Select the folder where the labels should export (sub-RID####/ses-clinical01/ieeg)

  • Set the file type to “ TXT (*.txt) “
  • Edit voxel coordinates text file for format compatibility
    • The reconstruction looks for coordinates that are integers (no decimals).
      • Open the voxel coordinate text file with Sublime Text (or a text editor of your choice)
      • Press command + f (Mac) or control + f (Windows) and type “.0” in the search bar.
      • Select “find all” and delete all “.0” characters.
      • Re-save the coordinates.

Electrode voxel coordinate text file, sub-RID#### placeholder (duplicate)

PART III: Running Reconstruction: can be done via Docker or terminal with Python in Leif (mounted via Borel)

  • Set up the correct folder structure in your Desktop:
    • Parent folder: sub-RID####BIDS folder tree for sub-RID0981 (duplicate)
      • Sub-directory: ses-clinical01
        • anat
          • sub-RID####_ses-clinical01_acq-3D_space-T00mri_T1w.nii.gz
        • ct
          • sub-RID####_ses-clinical01_acq-3D_space-T01ct_ct.nii.gz
        • ieeg
          • sub-RID####_ses-clinical01_space-T01ct_desc-vox_electrodes.txt
  • Move the sub-RID#### folder from your desktop into the Borel server:
    • Make sure you are connected to AirPennNet. If not, follow these steps:
      • Turn on GlobalProtect and sign in with your PennKey and password when promptedGlobalProtect VPN connected status (duplicate)
    • Open the terminal and navigate to your Desktop with this command: cd /Desktop
    • Then type the command below to copy the sub-RID#### folder into Borel:
  • Change the permissions of the sub-RID#### in Borel
    • In the terminal, ssh into the Borel server with:
    • Type:
      • cd /mnt/leif/littlab/data/Human_Data/recon/BIDS_musc
    • Type:
      • chmod 777 -R sub-RID####
    • Then navigate to the code folder with this command:
      • cd ../code
  • Run the reconstruction with this code:
    • python run_musc_recons.py
    • This code runs through every subject in the BIDS folders and creates a derivatives folder for the output. If a subject already has a derivatives folder, it will not be reconstructed.
    • If an error has occurred and you need to re-run a subject, you must first delete the derivatives folder.
    • The output of the reconstruction is module 2 (containing the ITK-SNAP workspace) and module 3: Finder listing of ieeg_recon derivatives for sub-RID0981 (duplicate)
  • Move the sub-RID#### folder from Borel back into your local Downloads so you can upload to Box:
    • Open a new terminal window
    • Navigate to Downloads with: cd /Downloads
    • Copy from Borel to Downloads with:

PART IV: Create ITK-SNAP Workspace

  • Go to the module2 folder in your Downloads (sub-RID####/ses-clinical01/derivatives/ieeg_recon/module2)
  • Right-click on the sub-RID####_ses-clinical01_itksnap_workspace.itksnap file and open it in ITK-SNAP (this file has the red ITK-SNAP icon next to it)
    • Scroll through to make sure the colored electrode coordinates line up with the coregistered MRI/CT
  • Import the label descriptions so that electrode names are visible when hovering over each coordinate
    • Click Segmentation and scroll to Import Label Descriptions.
    • The Open Label Descriptions pop-up will prompt you to specify the label description file
    • Click Browse and select sub-RID####_ses-clinical01_space-T01ct_desc-vox_electrodes_itk_snap_labels.txt
    • Save the ITK-SNAP file with these edits
  • Upload the reconstruction to PennBox.
    • Go to Penn Box
    • Go to Penn_MUSC_R01 → MUSC_Subject_Data → MUSC_Epilepsy_Patient Data → SEEG_Implant_Reconstruction → 3T subject ID folder
    • Drag and drop the entire sub-RIDXXXX folder from your Downloads (NOT YOUR DESKTOP) into this MUSC folder

Part V: Send email to the MUSC Coordinator and the MUSC PI to let them know the reconstruction is complete and has been uploaded