### MATLAB Configuration Example Source: https://github.com/penn-cnt/ieeg-recon/blob/main/MATLAB/README.md Configure external library paths, FSL, ITK-SNAP, and FreeSurfer within the MATLAB environment. Replace placeholder paths with your actual installation locations. ```matlab %% Set external library in path addpath(genpath('/path/to/your/dependencies')) %% FSL Setup setenv('FSLDIR', '/path/to/fsl'); setenv('FSLOUTPUTTYPE', 'NIFTI_GZ'); fsldir = getenv('FSLDIR'); fsldirmpath = sprintf('%s/etc/matlab', fsldir); path(path, fsldirmpath); clear fsldir fsldirmpath; %% ITK Snap Setup setenv('ITKSNAPDIR', '/path/to/ITK-SNAP'); itksnapdir = getenv('ITKSNAPDIR'); itksnapmpath = sprintf('%s', itksnapdir); path(path, itksnapmpath); clear itksnapdir itksnapmpath; %% Freesurfer setup setenv('FREESURFER_HOME', '/path/to/freesurfer'); setenv('SUBJECTS_DIR', '/path/to/your/subjects_dir'); FREESURFER_HOME = getenv('FREESURFER_HOME'); freesurferdirmpath = sprintf('%s/SetUpFreeSurfer.sh', FREESURFER_HOME); system(['sh ' freesurferdirmpath], '-echo'); clear freesurferdirmpath FREESURFER_HOME; ``` -------------------------------- ### Install iEEG-recon GUI Docker Version Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Installing_the_GUI.md Execute this script after cloning the repository to install the Docker version of the iEEG-recon GUI. Ensure Docker is installed and running beforehand. ```bash bash ieeg-recon/python/install_ieeg-recon_gui_docker.sh ``` -------------------------------- ### Example Data File Structure Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/Getting Started.md This is a concrete example of the file structure for sample data, demonstrating the organization for multiple subjects and sessions. ```text /path/to/exampleData/ | |__ sub-RID0675/ |     | __ ses-clinical01/ |     |     | __anat/ |     |     |     | __ sub-RID0675_ses-clinical01_acq-3D_space-T00mri_T1w.nii.gz |     |     | __ct/ |     |     |     | __ sub-RID0675_ses-clinical01_acq-3D_space-T01ct_ct.nii.gz |     |     | __ieeg/ |     |           | __ sub-RID0675_ses-clinical01_space-T01ct_ desc-vox_electrodes.txt |     | __ ses-research3T/ |     |     | __anat/ |     |     |     | __ sub-RID0675_ses-research3T_acq-3D_space-T00mri_T1w.nii.gz | __ sub-RID0864/ | __ sub-RID0922/ ``` -------------------------------- ### Verify Voxtool Installation Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Manual_Voxtool_Installation.md Run the voxtool launch script to verify the installation. This command should be executed within the activated 'vt' environment. ```python python ieeg-recon/voxTool/launch_pyloc.py ``` -------------------------------- ### Install VoxTool Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 1.md Install the VoxTool package using pip. This is a prerequisite for running the application from the command line. ```bash $ pip install voxtool ``` -------------------------------- ### Install iEEG-recon GUI with Docker (M1/M2) Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/Getting Started.md Use this script to install the iEEG-recon GUI on M1/M2 Macs when using Docker. Ensure Docker is installed and configured. ```console $ bash ieeg-recon/python/install_ieeg-recon_gui_m1m2.sh ``` -------------------------------- ### Install Greedy and C3D Command-Line Tools Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Installs the command-line tools for Greedy and C3D, which are often bundled with ITK-SNAP. This command assumes ITK-SNAP is installed in the default Applications directory. ```bash sudo /Applications/ITK-SNAP.app/Contents/bin/install_cmdl.sh ``` -------------------------------- ### Install ANTs using Homebrew and Custom Script Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Installs ANTs (Advanced Normalization Tools) by first installing Homebrew, then cmake, and finally executing a custom installation script for ANTs. Ensure Homebrew is added to your PATH. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install cmake mkdir ANTs cd ANTs curl -o installANTs.sh https://raw.githubusercontent.com/cookpa/antsInstallExample/master/installANTs.sh bash installANTs.sh ``` -------------------------------- ### Install iEEG-recon GUI on Windows Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Windows_Installation_Instructions.md Executes the installation script for the iEEG-recon GUI on Windows. This script is located within the cloned repository. ```bash bash ieeg-recon/python/install_ieeg-recon_gui_windows.sh ``` -------------------------------- ### Install Voxtool Dependencies Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Manual_Voxtool_Installation.md Install all required packages for voxtool within the activated 'vt' environment. Install packages one by one to ensure correct setup. ```conda conda install vtk && conda install pyqt=4 && conda install mayavi && conda install nibabel && conda install pydicom=1.2 && conda install matplotlib && conda install yaml && conda install pyyaml ``` -------------------------------- ### Run Miniconda Installer Script Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Manual_Voxtool_Installation.md Execute the Miniconda installation script on macOS and Linux systems. Ensure you have downloaded the correct installer for your system. ```bash bash Miniconda3-latest-MacOSX-x86_64.sh ``` -------------------------------- ### Install iEEG-Recon GUI for M1/M2 Macs Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Bash script to install the iEEG-Recon GUI on M1/M2 Macs, requiring Rosetta. This is a specific installation method for Apple Silicon hardware. ```bash bash python/install_ieeg-recon_gui_m1m2.sh ``` -------------------------------- ### Install Git using Conda Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Windows_Installation_Instructions.md Installs the Git version control system using the Conda package manager. This is a prerequisite for cloning the repository. ```bash conda install git ``` -------------------------------- ### Install iEEG-recon GUI Native Python Version Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Installing_the_GUI.md Run this script after cloning the repository to install the native Python version of the iEEG-recon GUI. This requires FSL, ANTs, and C3D to be pre-installed. ```bash bash ieeg-recon/python/install_ieeg-recon_gui_m1m2.sh ``` -------------------------------- ### Verify Docker Installation (Windows/Mac) Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Docker_Installation.md Run these commands in your terminal or command prompt to check if Docker is installed correctly and can pull and run images. ```bash docker --version ``` ```bash docker run hello-world ``` -------------------------------- ### Run VoxTool Application Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 1.md Launch the VoxTool application from the command line. This command starts the graphical user interface for electrode labeling. ```bash $ voxtool ``` -------------------------------- ### Python: Run Full Pipeline (Modules 2 + 3) Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Execute the complete iEEG-Recon pipeline, including Modules 2 and 3, using a Python script. This example uses Greedy registration, AntsPyNet segmentation, MNI output, and a 2mm radius. ```bash conda activate ieeg_recon cd python # Run full pipeline (Modules 2 + 3) with Greedy, AntsPyNet, MNI output, 2mm radius python ieeg_recon.py \ -s sub-RID0031 \ -d /path/to/BIDS \ -rs ses-research3T \ -cs ses-clinical01 \ -m -1 \ -gc \ -apn \ -mni \ -r 2 ``` -------------------------------- ### Install VoxTool Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Install the VoxTool package using pip. This tool is used for manually labeling electrode contacts in CT scans. ```bash pip install voxtool ``` -------------------------------- ### Configure MATLAB Environment for iEEG-recon Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/Getting Started.md Set FSLDIR and ITKSNAPDIR environment variables in MATLAB's startup.m file. Update paths to match your FSL and ITK-Snap installations. ```matlab %% in MATLAB/startup.m % Set FSLDIR to FSL install location setenv( 'FSLDIR', '/usr/local/fsl' ); setenv('FSLOUTPUTTYPE', 'NIFTI_GZ'); fsldir = getenv('FSLDIR'); fsldirmpath = sprintf('%s/etc/matlab',fsldir); path(path, fsldirmpath); clear fsldir fsldirmpath; % Set ITKSNAPDIR to ITK-Snap install location setenv('ITKSNAPDIR', '/Applications/ITK-SNAP.app/Contents/bin'); itksnapdir = getenv('ITKSNAPDIR'); itksnapmpath = sprintf('%s',itksnapdir); path(path,itksnapmpath) clear itksnapdir itksnapmpath; ``` -------------------------------- ### Install FSL using Conda Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Installs FSL (FMRIB Software Library) using a provided Python script. This is a recommended method for installing FSL. ```bash curl -o fslinstaller.py https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py python fslinstaller.py ``` -------------------------------- ### Run iEEG-Recon with FLIRT-only Registration Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Example command to run ieeg_recon.py using FLIRT for registration, falling back when Greedy is not available or preferred. Omits the -gc/-g flags. ```bash # Fall back to FLIRT-only registration by omitting -gc/-g flags python ieeg_recon.py -s sub-RID0922 -m 2 -cs ses-clinical01 -rs ses-clinical01 -d /path/to/BIDS ``` -------------------------------- ### Verify Greedy Installation for iEEG-Recon Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Command to check if the Greedy registration tool is installed and available in the PATH. Required for certain registration options in iEEG-Recon. ```bash # Verify Greedy is on PATH (if using -gc or -g) greedy --version ``` -------------------------------- ### BIDS-like Data Structure Example Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/Getting Started.md This illustrates the required folder and file structure for subject data. Ensure your data adheres to this organization for iEEG-recon processing. ```text BIDS/ | |__ sub-XXXX/ | | | __ ses-YYYY/ |     | __anat/ |     |       | __ sub-XXXX_ses-YYYY_acq-3D_space-T00mri_T1w.nii.gz |     | __ct/ |     |       | __ sub-XXXX_ses-YYYY_acq-3D_space-T01ct_ct.nii.gz |     | __ ieeg/ |         | __ sub-XXXX_ses-YYYY_space-T01ct_ desc-vox_electrodes.txt ``` -------------------------------- ### Clone iEEG-recon Repository Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/Getting Started.md Clone the iEEG-recon repository to your local machine to begin the installation process. ```console $ git clone git@github.com:penn-cnt/ieeg-recon.git ``` -------------------------------- ### Run iEEG-Recon Pipeline with Singularity Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Execute the iEEG-Recon pipeline using Singularity, mounting your local BIDS directory. This command is functionally equivalent to the Docker example, using Singularity's bind mount syntax. ```bash singularity run -B Desktop/BIDS/:/source_data ieeg_recon_1.0.sif -s sub-RID0031 -d /source_data -cs ses-clinical01 -rs ses-research3T -gc -m -1 -apn -r 2 ``` -------------------------------- ### Use Glasser360 Atlas with Custom Lookup Table Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Example of running ieeg_recon.py with the Glasser360 atlas and a custom lookup table. Ensure the atlas NIfTI file and the lookup table path are correctly specified. ```bash # Example: use the Glasser360 atlas with a custom lookup table python ieeg_recon.py \ -s sub-RID0031 \ -d /path/to/BIDS \ -rs ses-research3T \ -cs ses-clinical01 \ -m 3 \ -r 2 \ -a /path/to/glasser360_atlas.nii.gz \ -an glasser360 \ -lut python/source_data/standard_atlases/glasser360/glasser360NodeNames.txt ``` -------------------------------- ### Install iEEG-Recon Conda Environment for M1/M2 Macs Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Installs the iEEG-Recon pipeline using a specific script for M1/M2 Apple devices. After running this, activate the 'ieeg_recon_m1' environment. ```bash bash ieeg-recon/python/install_ieeg-recon_m1m2.sh ``` -------------------------------- ### Clone iEEG-recon Repository Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Installing_the_GUI.md Use this command to clone the iEEG-recon repository from GitHub. This is a prerequisite for both Docker and native installations. ```bash git clone https://github.com/penn-cnt/ieeg-recon.git ``` -------------------------------- ### Pull Docker Image Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Download the latest Docker image for iEEG-Recon. Ensure Docker is installed and running before executing this command. ```bash docker pull lucasalf11/ieeg_recon ``` -------------------------------- ### View iEEG-Recon Quality Assurance Report Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Example command to open the generated HTML QA report. This report includes registration overlays and interactive 3D electrode scatter plots. ```python # Example: view the report open sub-RID0922_ses-clinical01_report.html ``` -------------------------------- ### Clone Repository and Create Conda Environment Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Clone the iEEG-Recon repository and create a conda environment with all necessary Python dependencies. Ensure FSL is installed and its directory is exported. ```bash git clone git@github.com:penn-cnt/ieeg-recon.git cd ieeg-recon conda env create -f python/ieeg_recon_config.yml conda activate ieeg_recon curl -o fslinstaller.py https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py python fslinstaller.py export FSLDIR=~/fsl export PATH=${FSLDIR}/bin:${PATH} ``` -------------------------------- ### Verify FSL Installation for iEEG-Recon Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Command to check if FSL (FMRIB Software Library) is correctly installed and accessible in the PATH. This is crucial for troubleshooting Module 2 failures. ```bash # Verify FSL is correctly on PATH flirt -version ``` -------------------------------- ### Install iEEG-Recon Conda Environment Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Creates a new conda environment named 'ieeg_recon_m1' for the iEEG-Recon pipeline. Activate this environment before running pipeline commands. ```bash bash ieeg-recon/python/install_ieeg-recon.sh ``` -------------------------------- ### Configure FSL Environment Source: https://github.com/penn-cnt/ieeg-recon/blob/main/MATLAB/README.md Add FSL to your shell profile by setting the FSLDIR environment variable and sourcing the FSL setup script. This is necessary for the pipeline to access FSL tools. ```bash export FSLDIR=/path/to/fsl source ${FSLDIR}/etc/fslconf/fsl.sh export PATH=${FSLDIR}/bin:${PATH} ``` -------------------------------- ### Configure MATLAB Environment Paths Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Set up necessary environment variables and paths in MATLAB's startup.m file for FSL and ITK-SNAP. This ensures the MATLAB environment can find and utilize these tools. ```matlab %% MATLAB/startup.m % FSL setup setenv('FSLDIR', '/usr/local/fsl'); setenv('FSLOUTPUTTYPE', 'NIFTI_GZ'); fsldir = getenv('FSLDIR'); fsldirmpath = sprintf('%s/etc/matlab', fsldir); path(path, fsldirmpath); clear fsldir fsldirmpath; % ITK-SNAP setup setenv('ITKSNAPDIR', '/Applications/ITK-SNAP.app/Contents/bin'); itksnapdir = getenv('ITKSNAPDIR'); path(path, sprintf('%s', itksnapdir)); clear itksnapdir; ``` -------------------------------- ### Run Module 3 with Docker Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 3.md Execute Module 3 using Docker. Mount your data directory to \/source_data within the container. Ensure the path to your BIDS directory is absolute. ```bash $ docker run -v absolute/path/to/exampleData:/source_data lucasalf11/ieeg_recon -s sub-RID0922 -m 3 -cs ses-clinical01 -rs ses-clinical01 -r 2 -apn -mri -d /source_data ``` -------------------------------- ### Run Module 2 with MATLAB Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 2.md Set up subject and data paths in MATLAB, then instantiate the ieeg_recon object and call module2 to perform the registration. ```matlab % Set up subID = 'sub-RID0922'; % subject ID ct_session = 'ses-clinical01'; % name of session with CT scan mri_session = 'ses-clinical01'; % name of session with reference MRI scan BIDS_dir = '../exampleData'; % path to BIDS directory subject_rid922 = ieeg_recon(subID, ct_session, mri_session, BIDS_dir); % Run Module 2 fileLocations = subject_rid922.module2; ``` -------------------------------- ### Launch VoxTool Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Launches the VoxTool application for loading scans and defining electrode leads. Follow the numbered steps for a typical workflow. ```bash voxtool ``` -------------------------------- ### Initialize and Run Module 1 Source: https://github.com/penn-cnt/ieeg-recon/blob/main/MATLAB/README.md Initialize the iEEGReconPipeline object and execute Module 1 to extract electrode coordinates from post-implant CT scans. ```matlab % Initialize the pipeline object obj = iEEGReconPipeline(); % Run Module 1 obj.module1(); ``` -------------------------------- ### Run Module 2: CT-to-MRI Registration (Docker) Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Executes Module 2 for CT-to-MRI registration using Docker. Mounts the BIDS directory to the container for processing. ```bash docker run -v /path/to/BIDS:/source_data lucasalf11/ieeg_recon \ -s sub-RID0922 \ -m 2 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /source_data \ -gc ``` -------------------------------- ### Run Module 2 with Docker Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 2.md Execute Module 2 using Docker. Ensure your data is mounted to the container and specify subject, module, and session details. The -gc flag enables Greedy registration. ```console $ docker run -v absolute/path/to/exampleData:/source_data lucasalf11/ieeg_recon -s sub-RID0922 -m 2 -cs ses-clinical01 -rs ses-clinical01 -d /source_data | Arguments: | -s: subject ID | -m: Module number | -cs: name of session with CT scan | -rs: name of session with reference MRI scan | -d: path to BIDS directory | -gc: (optional, recommended) run with Greedy ``` -------------------------------- ### Run iEEG-Recon with Docker Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Execute the iEEG-Recon pipeline using a Docker container. Mount your BIDS directory to the container's /source_data path. ```bash docker run -v /path/to/BIDS:/source_data lucasalf11/ieeg_recon \ -s sub-RID0922 \ -m 3 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /source_data \ -r 2 \ -apn \ -mni ``` -------------------------------- ### Activate iEEG-Recon Conda Environment Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Activates the 'ieeg_recon_m1' conda environment. This command must be run to use the iEEG-Recon pipeline after installation. ```bash conda activate ieeg_recon_m1 ``` -------------------------------- ### Initialize and Run Module 3 in MATLAB Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Initialize a subject object in MATLAB and run Module 3 to generate output files. Ensure the BIDS directory path is correct. ```matlab subID = 'sub-RID0922'; ct_session = 'ses-clinical01'; mri_session = 'ses-clinical01'; BIDS_dir = '../exampleData'; subject = ieeg_recon(subID, ct_session, mri_session, BIDS_dir); % Run Module 3 fileLocations = subject.module3(); ``` -------------------------------- ### Run Module 2: CT-to-MRI Registration (Python) Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Executes Module 2 for CT-to-MRI registration using Python. Supports Greedy centering (recommended), full Greedy correction, or fallback FLIRT registration. ```bash conda activate ieeg_recon cd python # Run Module 2 with Greedy centering (recommended) python ieeg_recon.py \ -s sub-RID0922 \ -m 2 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS \ -gc # Run Module 2 with full Greedy correction python ieeg_recon.py \ -s sub-RID0922 \ -m 2 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS \ -g # Run Module 2 with default FLIRT only (fallback if Greedy fails) python ieeg_recon.py \ -s sub-RID0922 \ -m 2 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS ``` -------------------------------- ### Run iEEG-Recon Pipeline with Docker Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Execute the full iEEG-Recon pipeline (Modules 2 + 3) using a Docker container. Mount your BIDS data directory and specify subject, session, and processing parameters. ```bash docker pull lucasalf11/ieeg_recon docker run -v /path/to/BIDS:/source_data lucasalf11/ieeg_recon \ -s sub-RID0031 \ -d /source_data \ -cs ses-clinical01 \ -rs ses-research3T \ -gc \ -m -1 \ -apn \ -r 2 ``` -------------------------------- ### Add ANTs to PATH Environment Variable Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Appends the ANTs installation's binary directory to the system's PATH environment variable. This allows ANTs commands to be run from the terminal. The command is added to the Zsh configuration file. ```bash export PATH=~/ANTs/install/bin:$PATH echo "export PATH=~/ANTs/install/bin:$PATH" >> ~/.zshrc ``` -------------------------------- ### Run Module 2 with Python Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 2.md Execute Module 2 using a Python script after activating the conda environment. Specify subject, module, and session details. The -gc flag enables Greedy registration, which is recommended. ```console $ conda activate ieeg_recon $ cd python $ python ieeg_recon.py -s sub-RID0922 -m 2 -cs ses-clinical101 -rs ses-clinical01 -d absolute/path/to/exampleData -gc | Arguments: | -s: subject ID | -m: Module number | -cs: name of session with CT scan | -rs: name of session with reference MRI scan | -d: path to BIDS directory | -gc: (optional, recommended) run with Greedy ``` -------------------------------- ### Run iEEG-recon GUI Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Windows_Installation_Instructions.md Launches the iEEG-recon GUI application using Python. Ensure the 'ieeg_recon' environment is activated before running this command. ```python python ieeg-recon/python/ieeg_recon_gui_docker_windows.py ``` -------------------------------- ### Run Module 2: CT-to-MRI Registration (MATLAB) Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Executes Module 2 for CT-to-MRI registration using MATLAB. Initializes the subject and calls the module function. ```matlab subID = 'sub-RID0922'; ct_session = 'ses-clinical01'; mri_session = 'ses-clinical01'; BIDS_dir = '../exampleData'; subject = ieeg_recon(subID, ct_session, mri_session, BIDS_dir); % Run Module 2 with Greedy centering fileLocations = subject.module2('gc', false); ``` -------------------------------- ### Run iEEG-Recon Pipeline with Singularity Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Execute the iEEG-Recon pipeline using a Singularity container. Ensure the container is pulled and converted from Docker, and mount your BIDS data directory. ```bash singularity pull docker://lucasalf11/ieeg_recon:1.0 singularity run -B /path/to/BIDS:/source_data ieeg_recon_1.0.sif \ -s sub-RID0031 \ -d /source_data \ -cs ses-clinical01 \ -rs ses-research3T \ -gc \ -m -1 \ -apn \ -r 2 ``` -------------------------------- ### Launch VoxTool Program Source: https://github.com/penn-cnt/ieeg-recon/blob/main/voxTool/README.md Execute this command to launch the VoxTool application after activating the Conda environment. ```bash python launch_pyloc.py ``` -------------------------------- ### Run Module 3: Atlas-Based ROI Assignment (AntsPyNet) Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Executes Module 3 for atlas-based ROI assignment using the AntsPyNet atlas. Supports DKT + Atropos segmentation and MNI registration for visualization. ```bash conda activate ieeg_recon cd python # Run Module 3 with AntsPyNet DKT + Atropos segmentation, 2 mm electrode radius python ieeg_recon.py \ -s sub-RID0922 \ -m 3 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS \ -r 2 \ -apn # Add MNI registration for visualization python ieeg_recon.py \ -s sub-RID0922 \ -m 3 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS \ -r 2 \ -apn \ -mni ``` -------------------------------- ### Run Module 3 with AntSpyNet Atlas (Matlab) Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 3.md Initialize and run Module 3 in Matlab. This involves setting up subject and data paths, creating an ieeg_recon object, and then accessing the module3 functionality. ```matlab % Set up subID = 'sub-RID0922'; % subject ID ct_session = 'ses-clinical01'; % name of session with CT scan mri_session = 'ses-clinical01'; % name of session with reference MRI scan BIDS_dir = '../exampleData'; % path to BIDS directory subject_rid922 = ieeg_recon(subID, ct_session, mri_session, BIDS_dir); % Run Module 3 fileLocations = subject_rid922.module3; ``` -------------------------------- ### Run Module 3 with AntSpyNet Atlas (Docker) Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 3.md Execute Module 3 using Docker with the AntSpyNet atlas. Ensure your data is mounted to the container and specify subject, session, and BIDS directory details. ```console $ docker run -v absolute/path/to/exampleData:/source_data lucasalf11/ieeg_recon -s sub-RID0922 -m 3 -cs ses-clinical101 -rs ses-clinical01 -d /source_data -r 2 -apn ``` -------------------------------- ### Run iEEG-Recon Pipeline Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Execute modules 2 and 3 of the iEEG-Recon pipeline with AntsPyNet segmentation and MNI registration. Ensure your BIDS directory structure and subject/session naming conventions are followed. ```bash python ieeg_recon.py -d Desktop/BIDS/ -s sub-RID0031 -rs ses-research3T -cs ses-clinical01 -m -1 -gc -apn -mni -r 2 ``` -------------------------------- ### Module 2 Output Files Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Lists the expected output files generated by Module 2, including QA reports, registration overlays, electrode coordinate files, and transform matrices. ```text sub-RID0922_ses-clinical01_report.html # HTML QA report sub-RID0922_ses-clinical01_T00mri_T01ct_registration.svg # Registration overlay sub-RID0922_ses-clinical01_space-T00mri_desc-mm_electrodes.txt # Electrode coords in MRI mm space sub-RID0922_ses-clinical01_space-T00mri_desc-vox_electrodes.txt # Electrode coords in MRI vox space sub-RID0922_ses-clinical01_electrode_names.txt # Electrode label names sub-RID0922_ses-clinical01_acq-3D_space-T00mri_ct_thresholded.nii.gz # Thresholded CT in MRI space sub-RID0922_ses-clinical01_acq-3D_space-T00mri_T1w_electrode_spheres.nii.gz # Electrode spheres in MRI sub-RID0922_ses-clinical01_T00mri_to_T01ct_fsl.mat # FSL transform matrix sub-RID0922_ses-clinical01_T01ct_to_T00mri_fsl.mat # Inverse FSL transform sub-RID0922_ses-clinical01_T00mri_to_T01ct_greedy.mat # Greedy transform (if -gc used) ``` -------------------------------- ### Run iEEG-Recon Pipeline with Docker Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/README.md Execute the iEEG-Recon pipeline within a Docker container, mounting your local BIDS directory. This command runs modules 2 and 3 with Greedy co-registration, AntsPyNet segmentation, and MNI registration. ```bash docker run -v Desktop/BIDS/:/source_data lucasalf11/ieeg_recon -s sub-RID0031 -d /source_data -cs ses-clinical01 -rs ses-research3T -gc -m -1 -apn -r 2 ``` -------------------------------- ### Run Module 3 for ROI Mapping Source: https://github.com/penn-cnt/ieeg-recon/blob/main/MATLAB/README.md Execute Module 3 to map extracted electrode coordinates to anatomical regions using a predefined atlas. ```matlab % Run Module 3 obj.module3(); ``` -------------------------------- ### Clone Repository Source: https://github.com/penn-cnt/ieeg-recon/blob/main/MATLAB/README.md Clone the iEEG implant reconstruction repository using Git. ```bash git clone https://github.com/n-sinha/iEEG_implant_reconstruction.git ``` -------------------------------- ### Source FSL Environment Variables Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Commands to set the FSLDIR environment variable and source the FSL configuration script. This is necessary if FSL is not automatically found in the PATH. ```bash # If not found, source FSL: export FSLDIR=~/fsl source ${FSLDIR}/etc/fslconf/fsl.sh export PATH=${FSLDIR}/bin:${PATH} ``` -------------------------------- ### Create Conda Environment for iEEG-recon Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/Getting Started.md Create a conda environment from the provided YAML file to manage iEEG-recon dependencies. Navigate to the python directory before running. ```console cd python $ conda env create -f ieeg_recon_config.yml ``` -------------------------------- ### Python: Run Full Pipeline with Brain Shift Correction Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Execute the full iEEG-Recon pipeline with brain shift correction enabled. This requires specifying the path to the FreeSurfer output directory. ```bash # Run full pipeline with brain shift correction python ieeg_recon.py \ -s sub-RID0031 \ -d /path/to/BIDS \ -rs ses-research3T \ -cs ses-clinical01 \ -m -1 \ -gc \ -apn \ -r 2 \ -bs \ -fs /path/to/freesurfer/sub-RID0031 ``` -------------------------------- ### Open ITK-SNAP Workspace for iEEG-Recon Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Command to open the ITK-SNAP workspace file generated by iEEG-Recon for manual verification of electrode positions and registration. ```bash # Example: open the ITK-SNAP workspace itksnap -w sub-RID0922_ses-clinical01_itksnap_workspace.itksnap ``` -------------------------------- ### Create Conda Environment Source: https://github.com/penn-cnt/ieeg-recon/blob/main/voxTool/README.md Use this command to create a Conda environment from the provided YAML file. This environment is named 'vt' and is required to run voxTool. ```bash conda env install -f conda_env.yml ``` -------------------------------- ### Run iEEG-recon App with Docker Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/Getting Started.md Execute the iEEG-recon application within a Docker container, mounting a local directory for data. This command includes options for subject, session, and processing modules. ```console $ docker run -v :/source_data lucasalf11/ieeg_recon -s sub- -cs ses- -rs ses- -gc -m -1 -apn -r 2 -d /source_data ``` ```console $ docker run -v /Users/username/:/source_data lucasalf11/ieeg_recon -s sub- -cs ses- -rs ses- -gc -m -1 -apn -r 2 -d /source_data ``` -------------------------------- ### Activate Voxtool Conda Environment Source: https://github.com/penn-cnt/ieeg-recon/blob/main/python/docs/Manual_Voxtool_Installation.md Activate the 'vt' conda environment. Ensure your shell is correctly initialized for Conda. ```conda conda activate vt ``` -------------------------------- ### Run Module 2 for Image Registration Source: https://github.com/penn-cnt/ieeg-recon/blob/main/MATLAB/README.md Execute Module 2 for CT-MRI co-registration. The `'gc'` option specifies greedy registration with image centering, and `false` disables visualization. ```matlab % Run Module 2 with greedy registration and no visualization fileLocations = obj.module2('gc', false); ``` -------------------------------- ### Run Module 3 with AntSpyNet Atlas (Python) Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 3.md Run Module 3 from the command line using Python after activating the conda environment. This command specifies the subject, sessions, BIDS directory, radius for electrode spheres, and enables AntsPyNet segmentation. ```console $ conda activate ieeg_recon $ cd python $ python ieeg_recon.py -s sub-RID0922 -m 3 -cs ses-clinical01 -rs ses-clinical01 -d ../exampleData -r 2 -apn ``` -------------------------------- ### Run Module 3: Atlas-Based ROI Assignment (FreeSurfer Atlas) Source: https://context7.com/penn-cnt/ieeg-recon/llms.txt Executes Module 3 for atlas-based ROI assignment using a custom FreeSurfer atlas. Supports combined lookup tables, separate index/label files, and MNI-space atlas conversion. ```bash # Using a combined lookup table CSV (index, label pairs) python ieeg_recon.py \ -s sub-RID0922 \ -m 3 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS \ -r 2 \ -a /path/to/atlas.nii.gz \ -an MyAtlasName \ -lut /path/to/DKTatlas_lut.csv # Using separate ROI index and label files python ieeg_recon.py \ -s sub-RID0922 \ -m 3 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS \ -r 2 \ -a /path/to/atlas.nii.gz \ -an MyAtlasName \ -ri /path/to/roi_indices.txt \ -rl /path/to/roi_labels.txt # Convert an MNI-space atlas to subject space before assignment python ieeg_recon.py \ -s sub-RID0922 \ -m 3 \ -cs ses-clinical01 \ -rs ses-clinical01 \ -d /path/to/BIDS \ -r 2 \ -a /path/to/mni_atlas.nii.gz \ -an AAL116 \ -lut /path/to/aal116_lut.csv \ -ca ``` -------------------------------- ### Run Module 3 with Conda Source: https://github.com/penn-cnt/ieeg-recon/blob/main/docs/source/module 3.md Execute Module 3 using the Python script after activating the conda environment. Navigate to the python directory before running the script. The \`-r\` flag is used for radius. ```bash $ conda activate ieeg_recon $ cd python $ python ieeg_recon.py -s sub-RID0922 -m 3 -cs ses-clinical101 -rs ses-clinical01 -d absolute/path/to/exampleData -r -apn -mni ``` -------------------------------- ### Activate Conda Environment Source: https://github.com/penn-cnt/ieeg-recon/blob/main/voxTool/README.md Activate the 'vt' Conda environment before running voxTool. This ensures all necessary dependencies are available. ```bash source activate vt ```