User Tools

Site Tools


neuroimagen:cpac

CPAC

Una opcion para preprocesar las imagenes fMRI es utilizar C-PAC.

Se instala bajando una imagen docker que he transformado a Singularity.

Sujetos individuales

Siguiendo la documentacion puede lanzarse como,

[osotolongo@brick01 mopead]$ singularity run --cleanenv -B /nas/data/mopead/bids:/bids_dataset -B /nas/data/mopead/cpac_out:/outputs -B /nas/data/mopead/tmp:/scratch /nas/software/cpac-latest.simg /bids_dataset /outputs participant --participant_label sub-0001

Nota: el tag –cleanenv es necesario para que singularity no tome las variables del bash_profile de la maquina sino las de la imagen.

y por supuesto, la primera vez no funciona,

         ***********************************
190516-08:51:36,763 nipype.workflow ERROR:
         could not run node: resting_preproc_sub-0001_ses-1.anat_preproc_afni_0.anat_skullstrip
190516-08:51:36,765 nipype.workflow INFO:
         crashfile: /outputs/crash/crash-20190516-084320-osotolongo-anat_skullstrip-28dd4540-f205-44b7-9ad2-c4af06706a15.pklz
190516-08:51:36,769 nipype.workflow INFO:
         ***********************************

Puedo cambiar el skullstrip para hacerlo con FSL, pero he de especificarlo en la configuracion del pipeline. Asi que me copio un archivo previo y lo cambio.

# Choice of using AFNI or FSL-BET to perform SkullStripping
skullstrip_option: [BET]

La orden ahora es ligeramente diferente pues he de especificar el archivo de configuracion del pipeline,

[osotolongo@brick01 mopead]$ singularity run --cleanenv -B /nas/data/mopead:/project -B /nas/data/mopead/bids:/bids_dataset -B /nas/data/mopead/cpac_out:/outputs -B /nas/data/mopead/tmp:/scratch /nas/software/cpac-latest.simg --pipeline_file /project/cpac_pipeline_config.yml /bids_dataset /outputs participant --participant_label sub-0002

183 minutos después,

    End of subject workflow resting_preproc_sub-0002_ses-1

    CPAC run complete:

        Pipeline configuration: analysis
        Subject workflow: resting_preproc_sub-0002_ses-1
        Elapsed run time (minutes): 184.085074282
        Timing information saved in /outputs/log/cpac_individual_timing_analysis.csv
        System time of start:      2019-05-16 09:17:52
        System time of completion: 2019-05-16 12:21:49

El output es enorme,

[osotolongo@brick01 mopead]$ ls cpac_out/output/pipeline_analysis_nuisance/sub-0002_ses-1/
alff_to_standard_smooth_zstd                    frame_wise_displacement_power
anatomical_brain                                functional_brain_mask
anatomical_csf_mask                             functional_brain_mask_to_standard
anatomical_gm_mask                              functional_freq_filtered
anatomical_reorient                             functional_nuisance_regressors
anatomical_to_mni_nonlinear_xfm                 functional_to_anat_linear_xfm
anatomical_to_standard                          functional_to_standard
anatomical_to_symmetric_mni_nonlinear_xfm       mean_functional_to_standard
anatomical_wm_mask                              mni_to_anatomical_nonlinear_xfm
ants_affine_xfm                                 motion_correct
ants_initial_xfm                                motion_params
ants_rigid_xfm                                  qc
ants_symmetric_affine_xfm                       qc_html
ants_symmetric_initial_xfm                      roi_timeseries
ants_symmetric_rigid_xfm                        spatial_map_timeseries
centrality_smooth_zstd                          spatial_map_timeseries_for_DR
dr_tempreg_maps_files_to_standard_smooth        symmetric_anatomical_to_standard
dr_tempreg_maps_zstat_files_to_standard_smooth  symmetric_mni_to_anatomical_nonlinear_xfm
falff_to_standard_smooth_zstd                   vmhc_fisher_zstd_zstat_map
frame_wise_displacement_jenkinson

Afortunadamente, la explicacion de cada directorio esta documentada.

Integrando en el cluster

El esquema para correr en el cluster es el de lanzar las imagenes de singularity en paralelo. Hay que hacer varias pruebas por si se solapan unas a otras pero en principio intentaremos lanzar unos 8 procesos por nodo (o menos).

Aqui el codigo

Nota: Al correr c-pac en el cluster dan errores de I/O. Esto puede ser debido a un intenso uso de la red o de disco. He de reducir el nuemro de lanzamientos concurrentes y probar de nuevo.

Output

C-PAC genera un directorio de output por cada sujeto analizado

[osotolongo@detritus mopead]$ ls cpac_out/output/pipeline_analysis_nuisance/
sub-0001_ses-1  sub-0003_ses-1  sub-0005_ses-1  sub-0007_ses-1  sub-0009_ses-1  sub-0012_ses-1  sub-0015_ses-1  sub-0018_ses-1  sub-0020_ses-1  sub-0022_ses-1
sub-0002_ses-1  sub-0004_ses-1  sub-0006_ses-1  sub-0008_ses-1  sub-0010_ses-1  sub-0014_ses-1  sub-0017_ses-1  sub-0019_ses-1  sub-0021_ses-1  sub-0023_ses-1

El output completo para cada sujeto se puede ver aqui.

Errores

Los errores que se obtienen son muy diversos y parece indicar que tienen que ver mas con la calidad de la adquisicion que con el software en si mismo.No obstante al fallar en distintos puntos del procesamiento es posible que algunos de los sujetos fallidos contengan los archivos de output para algun postprocesdo especifico. En cada caso se ha de buscar si existen estos archivos.

190529-07:56:45,394 nipype.workflow INFO:
         [Node] Setting-up "resting_preproc_sub-0004_ses-1.sinker_0_13" in "/scratch/working/resting_preproc_sub-0004_ses-1/sinker_0_13".
190529-07:56:46,61 nipype.workflow INFO:
         [Node] Running "sinker_0_13" ("nipype.interfaces.io.DataSink")
190529-07:56:46,617 nipype.workflow INFO:
         [Node] Finished "resting_preproc_sub-0004_ses-1.sinker_0_13".
srun: error: brick01: task 0: Exited with exit code 1
190529-08:02:22,31 nipype.workflow INFO:
         [Node] Outdated cache found for "resting_preproc_sub-0003_ses-1.qc_snr_0.std_dev_anat".
190529-08:02:22,347 nipype.workflow INFO:
         [Node] Running "std_dev_anat" ("nipype.interfaces.fsl.preprocess.ApplyWarp"), a CommandLine Interface with command:
applywarp --in=/scratch/working/resting_preproc_sub-0003_ses-1/qc_snr_0/_scan_rest_run-1/std_dev/sub-0003_task-rest_run-1_bold_calc_tshift_resample_volreg_calc_maths_tstat.nii.gz --ref=/scratch/working/resting_preproc_sub-0003_ses-1/anat_preproc_bet_0/anat_skullstrip_orig_vol/sub-0003_T1w_resample_calc.nii.gz --out=/scratch/working/resting_preproc_sub-0003_ses-1/qc_snr_0/_scan_rest_run-1/std_dev_anat/sub-0003_task-rest_run-1_bold_calc_tshift_resample_volreg_calc_maths_tstat_warp.nii.gz --premat=/scratch/working/resting_preproc_sub-0003_ses-1/func_to_anat_bbreg_0/_scan_rest_run-1/bbreg_func_to_anat/sub-0003_task-rest_run-1_bold_calc_tshift_resample_volreg_calc_tstat_flirt.mat --interp=trilinear
190529-08:02:25,845 nipype.workflow INFO:
         [Node] Finished "resting_preproc_sub-0003_ses-1.qc_snr_0.std_dev_anat".
srun: error: brick01: task 0: Exited with exit code 1
nipype.external.portalocker.LockException: (5, 'Input/output error')
190529-08:02:21,718 nipype.workflow INFO:
         [Node] Setting-up "resting_preproc_sub-0009_ses-1.qc_skullstrip_1.montage_skull.montage_a" in "/scratch/working/resting_preproc_sub-0009_ses-1/qc_skullstrip_1/montage_skull/montage_a".
190529-08:02:21,892 nipype.workflow INFO:
         [Node] Outdated cache found for "resting_preproc_sub-0009_ses-1.qc_skullstrip_1.montage_skull.montage_a".
190529-08:02:22,252 nipype.workflow INFO:
         [Node] Setting-up "_montage_a0" in "/scratch/working/resting_preproc_sub-0009_ses-1/qc_skullstrip_1/montage_skull/montage_a/mapflow/_montage_a0".
190529-08:02:22,286 nipype.workflow INFO:
         [Node] Outdated cache found for "_montage_a0".
190529-08:02:22,446 nipype.workflow INFO:
         [Node] Running "_montage_a0" ("CPAC.utils.function.Function")
190529-08:02:28,560 nipype.workflow INFO:
         [Node] Finished "_montage_a0".
190529-08:02:28,576 nipype.workflow INFO:
         [Node] Finished "resting_preproc_sub-0009_ses-1.qc_skullstrip_1.montage_skull.montage_a".
srun: error: brick01: task 0: Exited with exit code 1
nipype.external.portalocker.LockException: (5, 'Input/output error')
190529-08:04:01,614 nipype.workflow INFO:
         [Node] Setting-up "resting_preproc_sub-0001_ses-1.hist_vmhc_fisher_zstd_1" in "/scratch/working/resting_preproc_sub-0001_ses-1/_scan_rest_run-1/_selector_CSF-2mmE-M_aC-CSF+WM-2mm-DPC5_M-SDB_P-2_BP-B0.01-T0.1/_fwhm_4/hist_vmhc_fisher_zstd_1".
190529-08:04:01,676 nipype.workflow INFO:
         [Node] Outdated cache found for "resting_preproc_sub-0001_ses-1.hist_vmhc_fisher_zstd_1".
190529-08:04:01,713 nipype.workflow INFO:
         [Node] Running "hist_vmhc_fisher_zstd_1" ("CPAC.utils.function.Function")
190529-08:04:01,899 nipype.workflow INFO:
         [Node] Finished "resting_preproc_sub-0001_ses-1.hist_vmhc_fisher_zstd_1".
srun: error: brick03: task 0: Exited with exit code 1
         ***********************************
190529-09:10:47,524 nipype.workflow ERROR:
         could not run node: resting_preproc_sub-0014_ses-1.afni_centrality_0_eigenvector.afni_centrality.a0.b0
190529-09:10:47,527 nipype.workflow INFO:
         crashfile: /outputs/crash/crash-20190529-082639-osotolongo-afni_centrality.a0.b0-75dfa3ff-3c39-4800-b04d-c95080370a86.pklz
190529-09:10:47,530 nipype.workflow ERROR:
         could not run node: resting_preproc_sub-0014_ses-1.afni_centrality_1_eigenvector.afni_centrality.a0.b0
190529-09:10:47,533 nipype.workflow INFO:
         crashfile: /outputs/crash/crash-20190529-083301-osotolongo-afni_centrality.a0.b0-ee039f25-50ce-43c6-b64b-0d32355dd8c9.pklz
190529-09:10:47,535 nipype.workflow INFO:
         ***********************************
nipype.external.portalocker.LockException: (5, 'Input/output error')
190529-09:37:12,642 nipype.workflow INFO:
         [Node] Running "_apply_ants_warp_mapnode6" ("nipype.interfaces.ants.resampling.ApplyTransforms"), a CommandLine Interface with command:
antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input /scratch/working/resting_preproc_sub-0010_ses-1/temporal_dual_regression_0/_scan_rest_run-1/_selector_CSF-2mmE-M_aC-CSF+WM-2mm-DPC5_G-M_M-SDB_P-2_BP-B0.01-T0.1/_spatial_map_PNAS_Smith09_rsn10_spatial_map_file_..cpac_templates..PNAS_Smith09_rsn10.nii.gz/split_raw_volumes/temp_reg_map_0006.nii.gz --input-image-type 0 --interpolation Linear --output temp_reg_map_0006_antswarp.nii.gz --reference-image /usr/share/fsl/5.0/data/standard/MNI152_T1_3mm_brain.nii.gz --transform /scratch/working/resting_preproc_sub-0010_ses-1/anat_mni_ants_register_0/calc_ants_warp/transform3Warp.nii.gz --transform /scratch/working/resting_preproc_sub-0010_ses-1/anat_mni_ants_register_0/calc_ants_warp/transform2Affine.mat --transform /scratch/working/resting_preproc_sub-0010_ses-1/anat_mni_ants_register_0/calc_ants_warp/transform1Rigid.mat --transform /scratch/working/resting_preproc_sub-0010_ses-1/anat_mni_ants_register_0/calc_ants_warp/transform0DerivedInitialMovingTranslation.mat --transform /scratch/working/resting_preproc_sub-0010_ses-1/dr_tempreg_maps_files_fsl_to_itk_0/_scan_rest_run-1/_selector_CSF-2mmE-M_aC-CSF+WM-2mm-DPC5_G-M_M-SDB_P-2_BP-B0.01-T0.1/_spatial_map_PNAS_Smith09_rsn10_spatial_map_file_..cpac_templates..PNAS_Smith09_rsn10.nii.gz/change_transform_type/mapflow/_change_transform_type6/updated_affine.txt
190529-09:37:13,368 nipype.workflow INFO:
         [Node] Finished "_apply_ants_warp_mapnode6".
srun: error: brick01: task 0: Exited with exit code 1

Grupos

Hay diferentes niveles de analisis grupal, explicados en http://fcp-indi.github.io/docs/user/group_analysis.html. Primero ha de elegirse lo que se desee hacer.

neuroimagen/cpac.txt · Last modified: 2020/08/04 10:58 by 127.0.0.1