xcp_d.interfaces.bids module

Adapted interfaces from Niworkflows.

class xcp_d.interfaces.bids.CollectRegistrationFiles(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Collect registration files for fsnative-to-fsLR transformation.

Optional Inputs:
  • hemisphere (‘L’ or ‘R’) – The hemisphere being used.

  • participant_id (a string) – Participant ID. Used to select the subdirectory of the FreeSurfer derivatives.

  • segmentation_dir (a pathlike object or string representing an existing directory) – Path to FreeSurfer or MCRIBS derivatives.

  • software (‘FreeSurfer’ or ‘MCRIBS’) – The software used for segmentation.

Outputs:
  • source_sphere (a pathlike object or string representing an existing file) – Source-space sphere (namely, fsaverage).

  • sphere_to_sphere (a pathlike object or string representing an existing file) – Warp file going from source space to target space.

  • subject_sphere (a pathlike object or string representing an existing file) – Subject-space sphere.

  • target_sphere (a pathlike object or string representing an existing file) – Target-space sphere (fsLR for FreeSurfer, dHCP-in-fsLR for MCRIBS).

class xcp_d.interfaces.bids.CopyAtlas(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Copy atlas file to output directory.

Parameters:
  • name_source (str) – The source name of the atlas file.

  • in_file (str) – The atlas file to copy.

  • output_dir (str) – The output directory.

  • atlas (str) – The name of the atlas.

Returns:

out_file – The path to the copied atlas file.

Return type:

str

Notes

I can’t use DerivativesDataSink because it has a problem with dlabel CIFTI files. It gives the following error: “AttributeError: ‘Cifti2Header’ object has no attribute ‘set_data_dtype’”

I can’t override the CIFTI atlas’s data dtype ahead of time because setting it to int8 or int16 somehow converts all of the values in the data array to weird floats. This could be a version-specific nibabel issue.

I’ve also updated this function to handle JSON and TSV files as well.

Mandatory Inputs:
  • atlas (a string) – The atlas name.

  • in_file (a pathlike object or string representing an existing file) – The atlas file to copy.

  • output_dir (a pathlike object or string representing an existing directory) – The output directory.

Optional Inputs:

name_source (a string) – The source file’s name.

Outputs:

out_file (a pathlike object or string representing an existing file) – The copied atlas file.

class xcp_d.interfaces.bids.DerivativesDataSink(allowed_entities=None, out_path_base=None, **inputs)[source]

Bases: DerivativesDataSink

Store derivative files.

A child class of the niworkflows DerivativesDataSink, using xcp_d’s configuration files.

Mandatory Inputs:
  • in_file (a list of items which are a pathlike object or string representing an existing file) – The object to be saved.

  • source_file (a list of items which are a pathlike object or string representing a file) – The source file(s) to extract entities from.

Optional Inputs:
  • base_directory (a string or os.PathLike object) – Path to the base directory for storing data.

  • check_hdr (a boolean) – Fix headers of NIfTI outputs. (Nipype default value: True)

  • compress (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None, default). (Nipype default value: [])

  • data_dtype (a string) – NumPy datatype to coerce NIfTI data to, or source tomatch the input file dtype.

  • dismiss_entities (a list of items which are a string or None) – A list entities that will not be propagated from the source file. (Nipype default value: [])

  • meta_dict (a dictionary with keys which are a value of class ‘str’ and with values which are any value) – An input dictionary containing metadata.

Outputs:
  • compression (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None).

  • fixed_hdr (a list of items which are a boolean) – Whether derivative header was fixed.

  • out_file (a list of items which are a pathlike object or string representing an existing file)

  • out_meta (a list of items which are a pathlike object or string representing an existing file)

out_path_base = ''