Skip to content

Submodules of the Import Module


xASL_bids_AddGeneratedByField.m

Format:

xASL_bids_AddGeneratedByField(x, pathJSONin[, pathJSONout])

Description:

Add the generated by field to the struct.


xASL_bids_BIDS2Legacy.m

Format:

[dataPar] = xASL_bids_BIDS2Legacy(pathStudy, x[, bOverwrite, dataPar])

Description:

This function converts BIDS rawdata (in pathStudy/rawdata/) to xASL legacy derivative format (e.g. pathStudy/derivatives/ExploreASL/)

Can be updated step-by-step when ExploreASL's derivative structure moves to BIDS NB: ask how Visits/session layer is defined in bids-matlab (should be separate layer within subjects, but now isn't?)

This function performs the following steps:

  1. Parse a folder using bids-matlab
  2. Define Subject
  3. Define SubjectVisit
  4. Parse modality
  5. Parse scantype
  6. Compile paths for copying
  7. Manage sidecars to copy
  8. Copy files
  9. Parse M0
  10. Create DataPar.json
  11. Copy participants.tsv
  12. Add dataset_description.json
  13. Clean up

xASL_bids_BIDS2Legacy_CompilePathsForCopying.m

Format:

[bidsPar, TypeIs, pathOrig, pathDest] = xASL_bids_BIDS2Legacy_CompilePathsForCopying(bidsPar, TypeIs, ModalityIs, RunIs, iSubjSess, BIDS, TypeRunIndex, ModalityFields, pathLegacy_SubjectVisit)

Description:

Compile paths for BIDS to Legacy copying.


xASL_bids_BIDS2Legacy_ManageSidecars.m

Format:

[bidsPar, pathOrig, pathDest, TypeIs] = xASL_bids_BIDS2Legacy_ManageSidecars(bidsPar, pathOrig, pathDest, TypeIs)

Description:

Manage JSON sidecars for BIDS2Legacy conversion.


xASL_bids_BIDS2Legacy_ParseModality.m

Format:

xASL_bids_BIDS2Legacy_ParseModality(BIDS, bidsPar, SubjectVisit, iSubjSess, ModalitiesUnique, nModalities, bOverwrite, pathLegacy_SubjectVisit)

Description:

Parse modality for BIDS to Legacy conversion.


xASL_bids_BIDS2Legacy_ParseScanType.m

Format:

xASL_bids_BIDS2Legacy_ParseScanType(modalityConfiguration, SubjectVisit, RunsUnique, RunsAre, bOverwrite, Reference, bidsPar, ModalityIs, iSubjSess, BIDS, ModalityFields, pathLegacy_SubjectVisit)

Description:

Parse scan type during BIDS to Legacy conversion.


xASL_bids_BIDS2xASL_CopyFile.m

Format:

xASL_bids_BIDS2xASL_CopyFile(pathOrig, pathDest, bOverwrite)

Description:

Copy files for BIDS to Legacy conversion.


xASL_imp_AppendNiftiParameters.m

Format:

s = xASL_imp_AppendNiftiParameters(nii_files)

Description:

Append Nifti Parameters.


xASL_imp_AppendParmsParameters.m

Format:

[s, FieldNames] = xASL_imp_AppendParmsParameters(parms)

Description:

Append Parms Parameters.


xASL_imp_BIDS2Legacy.m

Format:

[x] = xASL_imp_BIDS2Legacy(x);

Description:

BIDS to Legacy conversion script which calls xASL_bids_BIDS2Legacy.

  1. Input check
  2. Start with checking dataset_description.json & rawdata
    1. The input is dataset_description.json in the rawdata folder
    1. The input is dataPar.json or sourceStructure.json - have to look for a rawdata folder
  3. Run the legacy conversion: Check if a dataPar is provided, otherwise use the defaults
  4. Overwrite DatasetRoot

xASL_imp_CatchErrors.m

Format:

[dcm2niiCatchedErrors] = xASL_imp_CatchErrors(WarningID, WarningMessage, WarningLine, WarningFileName, WarningPath, scan_name, scanpath, destdir, dcm2niiCatchedErrors, imPar, StackIn)

Description:

Catch reported warnings/errors, print them if verbose, & add them to a structure of warnings/errors to be stored for later QC.


xASL_imp_CreateSummaryFile.m

Format:

xASL_imp_CreateSummaryFile(imPar, PrintDICOMFields, x, fid_summary)

Description:

Create summary file.

  1. Create summary file
  2. Report totals

xASL_imp_DCM2NII.m

Format:

xASL_imp_DCM2NII(imPar, x)

Description:

Run the dcm2nii part of the import.

  1. Initialize defaults of dcm2nii
  2. Create the basic folder structure for sourcedata & derivative data
  3. Here we try to fix backwards compatibility, but this may break
  4. Redirect output to a log file
  5. Start with defining the subjects, visits, sessions (i.e. BIDS runs) and scans (i.e. ScanTypes) by listing or typing
  6. Sanity check for missing elements
  7. Import subject by subject, visit by visit, session by session, scan by scan

xASL_imp_DCM2NII_CheckIfFME.m

Format:

[resultJSON, bTimeEncoded, bTimeEncodedFME] = xASL_imp_DCM2NII_CheckIfFME(nii_files, bTimeEncoded, bTimeEncodedFME)

Description:

Check if the current sequence is a FME (Fraunhofer Mevis) time encoded sequence.


xASL_imp_DCM2NII_ReorderTimeEncoded.m

Format:

xASL_imp_DCM2NII_ReorderTimeEncoded(nii_files, bTimeEncoded, resultJSON)

Description:

Reorder TEs and PLDs accordingly for time encoded sequences.


xASL_imp_DCM2NII_Subject.m

Format:

[imPar, summary_lines, PrintDICOMFields, globalCounts, scanNames, dcm2niiCatchedErrors, pathDcmDict] = xASL_imp_DCM2NII_Subject(x, imPar, iSubject, matches, dcm2niiCatchedErrors)

Description:

Run DCM2NII for one individual subject.

  1. Run DCM2NII for one individual subject
  2. Iterate over visits
  3. Loop through all sessions
  4. Iterate over scans
    1. Initialize variables (scanID, summary_line, first_match)
    1. Convert scan ID to a suitable name and set scan-specific parameters
    1. Minimalistic feedback of where we are
    1. Now pick the matching one from the folder list
    1. Determine input and output paths
    1. Start the conversion if this scan should not be skipped
    1. Store JSON files
    1. In case of a single NII ASL file loaded from PAR/REC, we need to shuffle the dynamics from CCCC...LLLL order to CLCLCLCL... order
  5. 9 Copy single dicom as QC placeholder
    1. Store the summary info so it can be sorted and printed below

xASL_imp_DCM2NII_Subject_SortASLVolumes.m

Format:

[x, nii_files, summary_line, globalCounts, ASLContext] = xASL_imp_DCM2NII_Subject_SortASLVolumes(x, globalCounts, scanpath, scan_name, nii_files, iSubject, iSession, iScan)

Description:

Sort ASL Volumes.

  1. Fallbacks
  2. Fill NIfTI Table
  3. Get ASL context if possible
  4. Only try shuffling if you dont know the ASL context already
  5. Merge NIfTIs if there are multiples for ASL or M0, merge multiple files
  6. Extract relevant parameters from nifti header and append to summary file

xASL_imp_DCM2NII_Subject_StartConversion.m

Format:

[imPar, globalCounts, x, summary_line, destdir, scanpath, scan_name, dcm2niiCatchedErrors, nii_files, first_match] = xASL_imp_DCM2NII_Subject_StartConversion(imPar, globalCounts, x, bSkipThisOne, summary_line, destdir, scanpath, scan_name, dcm2niiCatchedErrors)

Description:

Start of DCM2NII subject conversion.


xASL_imp_DCM2NII_Subject_StoreJSON.m

Format:

[parms, pathDcmDict] = xASL_imp_DCM2NII_Subject_StoreJSON(imPar, SavePathJSON, first_match, bUseDCMTK, pathDcmDict)

Description:

Store JSON.


xASL_imp_Deface.m

Format:

xASL_imp_Deface(imPar)

Description:

Run defacing.

  1. Iterate over list of subjects
  2. Get subject labels
  3. Process all anatomical files (xASL\_spm\_deface)

xASL_imp_Initialize.m

Format:

imPar = xASL_imp_Initialize(studyPath, imParPath)

Description:

Initialize DCM2NII.

  1. Read study file
  2. Specify paths
  3. Finalize the directories
  4. Specify the tokens
  5. Specify the additional details of the conversion

xASL_imp_NII2BIDS.m

Format:

x = xASL_imp_NII2BIDS(x, imPar, studyPath, studyParPath)

Description:

Run the NII2BIDS conversion.

  1. Load the study parameters + dataset description
  2. Create the study description output and verify that all is there
  3. Go through all subjects and check all the M0 and ASLs and modify the JSONs

xASL_imp_NII2BIDS_Run.m

Format:

x = xASL_imp_NII2BIDS_Run(x, bidsPar, studyPar, subjectSessionLabel, inSessionPath, outSessionPath, listRuns, iRun)

Description:

NII2BIDS conversion for a single sessions, single runs.

  1. Convert anat files
  2. Convert perf files

xASL_imp_NII2BIDS_RunAnat.m

Format:

xASL_imp_NII2BIDS_RunAnat(bidsPar, studyPar, subjectSessionLabel, outSessionPath, listRuns, iRun, nameSubjectSession)

Description:

NII2BIDS conversion for a single sessions, single run.


xASL_imp_NII2BIDS_RunPerf.m

Format:

xASL_imp_NII2BIDS_RunPerf(bidsPar, studyPar, subjectSessionLabel, inSessionPath, outSessionPath, listRuns, iRun)

Description:

NII2BIDS conversion for a single sessions, single run.

  1. Define the pathnames
  2. Load the JSONs and NIfTI information
  3. BIDSify ASL
  4. Prepare the link to M0 in ASL.json
  5. BIDSify M0
  6. Save all ASL files (JSON, NIFTI, CONTEXT) to the BIDS directory

xASL_imp_NII2BIDS_Session.m

Format:

x = xASL_imp_NII2BIDS_Session(x, imPar, bidsPar, studyPar, listSessions, nameSubjectSession, bidsLabel, iSession)

Description:

NII2BIDS conversion for a single sessions.

  1. Make a subject directory
  2. Iterate over runs

xASL_imp_NII2BIDS_Subject.m

Format:

x = xASL_imp_NII2BIDS_Subject(x, imPar, bidsPar, studyPar, nameSubject)

Description:

Run NII to ASL-BIDS for one individual subject.

  1. Initialize
  2. Process the anat & perfusion files
    1. Make a subject directory
    1. Iterate over sessions
    1. Iterate over runs

xASL_imp_NII2BIDS_Subject_DefineM0Type.m

Format:

[jsonLocal, bJsonLocalM0isFile] = xASL_imp_NII2BIDS_Subject_DefineM0Type(studyPar, bidsPar, jsonLocal, pathM0, linkM0prefix)

Description:

Define M0 Type


xASL_imp_UpdateDatasetRoot.m

Format:

[x] = xASL_imp_UpdateDatasetRoot(x, studyPath)

Description:

Update x.opts.DatasetRoot to dataset_description.json after NII2BIDS conversion