Skip to content

2. List of the MAGIA functions

Tomi Karjalainen edited this page Apr 24, 2018 · 11 revisions

This page contains both a short list of the most important functions and instructions for their use, as well as a comprehensive list of functions.

The important functions

MAGIA

run_magia

run_magia is the function that the user calls to trigger analysis of a single study. It acts as an interface between magia_processor and metadata specification. In Turku PET Centre only one input argument, the study ID, is required. Everywhere else also the metadata and the modelling options must be specified.

The metadata must be given as a struct containing the following fields (please use exactly the following names): tracer, frames, use_mri, mri, plasma, rc, dynamic, dc, fwhm, dose and weight.

Also the modelling options must be arranged in a struct. The modelling options struct must always contain the field 'model'. In addition, the struct must contain model-specific fields.

srtm: lb, ub, theta3_lb, theta3_ub, nbases

patlak: start_time, end_frame

patlak_ref: start_time, cut_time, filter_size

fur: start_time, end_time, ic

suvr: start_time, end_time

magia_processor

magia_processor is the main workhorse of the pipeline. It processes a brain PET study with standardized methods. The processing method depends on the tracer, whether the study is dynamic or static, whether an MRI is available for FreeSurfing, and whether plasma input is available for modeling.

The first input argument defines a study id. The function assumes that a folder with exactly the same name exists under getenv('DATA_DIR').

AIVO

aivo_get_subjects is meant for selecting subjects from AIVO. Examples:

subjects = aivo_get_subjects('tracer','[18f]fdg','analyzed',1);
subjects = aivo_get_subjects('tracer','[11c]raclopride','analyzed',1,'mri','~0');

aivo_get_info is meant for reading information from AIVO. Examples:

subjects = aivo_get_subjects('tracer','[18f]fdg','analyzed',1);
weight = aivo_get_info(subjects,'weight');
height = aivo_get_info(subjects,'height');
bmi = weight./((height*0.01)^2);

aivo_set_info is meant for writing information to AIVO. Examples:

subjects = aivo_get_subjects('tracer','[18f]fdg','found',1,'mri','~0');
N = length(subjects);

for i = 1:N
   sub = subjects{i};
   freesurfed = magia_check_freesurfed(sub);
   aivo_set_info(sub,'freesurfed',freesurfed);
end

aivo_import is meant for creating new subjects to AIVO. The function reads a pre-filled spreadsheet and imports its contents to correct tables in AIVO. Please read this to get more information about how to fill in the metadata.


The comprehensive list of MAGIA functions

AIVO functions

  • aivo_check_found.m
  • aivo_connect.m
  • aivo_get_info.m
  • aivo_get_isotope_from_tracer.m
  • aivo_get_subjects.m
  • aivo_get_subjects_dev.m
  • aivo_parse_me.m
  • aivo_read_2tcm_modeling_options.m
  • aivo_read_fur_modeling_options.m
  • aivo_read_modeling_options.m
  • aivo_read_patlak_modeling_options.m
  • aivo_read_patlak_ref_modeling_options.m
  • aivo_read_srtm_modeling_options.m
  • aivo_read_suvr_dyn_modeling_options.m
  • aivo_set_info.m
  • aivo_set_modeling_options.m
  • aivo_store_magia_info.m
  • check_megabase_conn.m
  • magia_parse_me.m
  • magia_metadata_from_aivo.m
  • parse_frames_string.m
  • get_frame_string.m

Modeling functions

  • Gunn1997_nifti_mask.m
  • PatlakPlasma_nifti.m
  • PatlakRef_nifti.m
  • calculate_auc_ratio.m
  • calculate_fur.m
  • calculate_static_ratio.m
  • fit_srtm.m
  • magia_2tcm_3.m
  • magia_calculate_fur_image.m
  • simSRTM_1_0_0.m
  • roi_fitting.m
  • metpet_fit_patlak.m
  • metpet_fit_srtm_iterative.m
  • magia_fit_2tcm_iterative.m
  • magia_fit_patlak_ref.m
  • calculate_parametric_images.m
  • magia_get_patlak_default_options.m
  • magia_get_patlak_ref_default_options.m
  • magia_get_2tcm_default_options.m
  • magia_get_default_model.m
  • magia_get_fur_default_options.m
  • magia_suvr_dyn.m
  • magia_suvr_dyn_image.m
  • magia_suvr_static_image.m
  • magia_get_srtm_default_options.m
  • magia_get_suvr_dyn_default_options.m
  • calculate_fur_integral.m
  • metpet_random_init_srtm.m

MAGIA-specific

  • magia_archive_results.m
  • magia_calculate_input_boundaries.m
  • magia_clean_files.m
  • magia_combine_seg_and_bs.m
  • magia_dev_test.m
  • magia_get_githash.m
  • magia_get_pet_file.m
  • magia_get_ref_region.m
  • magia_identify_bad_frames.m
  • magia_max_consecutive_values.m
  • magia_processor.m
  • magia_recon_all.m
  • magia_test_dyn.m
  • magia_write_githash.m
  • magia_write_modeling_options2.m
  • run_magia.m
  • run_magia_dev.m
  • archive_results_new.m
  • calculate_input_boundaries.m
  • process_mri.m
  • decay_correct_to_injection_time.m

QC

  • MRIqc.m
  • add_to_qc_pic.m
  • coreg_qc.m
  • input_qc.m
  • parametric_image_qc.m
  • motion_parameter_qc.m
  • mri_histogram_qc.m
  • magia_input_qc.m

Elementary SPM functions

  • smooth_img.m
  • spm_coregister_estimate.m
  • spm_coregister_reslice.m
  • spm_dcm2nii_2.m
  • spm_nifti_dynamize.m
  • spm_segment.m
  • spm_write_4d_nifti.m
  • normalize_using_mri.m
  • normalize_using_template.m
  • motion_correction.m

Visualization

  • roi_bars.m
  • visualize_fits.m
  • visualize_tacs.m
  • plotshaded.m

Reference region generation

  • shrink_cer.m
  • shrink_oc_new.m
  • anatomical_reference_region_correction2.m
  • data_driven_reference_region_correction_fwhm.m

MAGIA check

  • magia_check_found.m
  • magia_check_freesurfed.m
  • magia_check_metadata.m
  • magia_check_mri_found.m
  • magia_check_plasma_found.m
  • magia_check_reversed.m

Image conversion

  • convert_ecat2nii.m
  • convert_to_nifti.m
  • magia_convert_to_nifti.m

Brainmask

  • create_brainmask.m
  • metpet_fill_brain_img.m
  • metpet_fill_line.m
  • metpet_fill_slice.m

Plasma inputs

  • read_plasma.m
  • read_plasma_dft.m
  • metpet_read_plasma_data.m

String handling

  • add_postfix.m
  • add_prefix.m
  • get_filenames.m

Center images

  • center_image.m
  • center_image2.m
  • cg_set_com_mod.m

ROI level stuff

  • calculate_roi_tacs.m
  • create_roi_masks2.m
  • create_specific_binding_mask.m
  • get_atlas_rois.m
  • get_roi_masks.m
  • get_tracer_default_roi_set.m
  • magia_get_roi_info.m
  • remove_nonspecific_binding_from_rois.m

Others

  • PSVsmooth_3d.m
  • fit_gaussian_mixture.m
  • get_ref_tac.m
  • get_voxel_time_series.m