Skip to content

Code rationale, definitions and structure

Sebastiano Ferraris edited this page Sep 9, 2017 · 7 revisions

Code rationale

The code is written an runs in Python 2.7 and, from version 1.0.1 in Python 3 (back compatible to 2.7).

The choice of Python as programming language is after personal preferences, the availability of nibabel library, the availability of dictionaries (mapping) type and numpy arrays, that appears to be the best option to parse the textfiles of Paravision into easily accessible structures while keeping the original naming convention.

Definitions

study: a series of acquisition related to the same subject, acquired in the same scanning session and usually containing multiple scans. It is provided as a folder structure containing the scans produced with paravision (PV) software. Patient/subject information are embedded in the study (opposed hierarchy as in the DICOM files).

scan or experiment, sub-scans and sub-volumes: individual folder image acquired with various protocols. To a scan can belong more than one processed image, or reconstruction. Each processed image can be a single volume or can contain more than one sub-volume embedded in the same processed image.

header: header of the nifti format.

img_data: array data of the nifti format, stored in a 2d or 3d matrix.

struct: intermediate structure (python dictionary) proposed in this code, aimed at collecting the information from the raw Bruker and to progressively creating the nifti images.

Code structure:

  • bruker2nifti._cores.py contains the core of the parser. It is not possible to disentangle the information of some of the raw Bruker files and parse them individually with individual parsers to create the nifti. Data useful to build the nifti are stored in an intermediate structure, called struct (yes, I know...), that is than used to create and save the nifti image(s) and the file.
  • bruker2nifti._utils.py contains the utils, whose core is the method indian_file_parser component of the bridge parsing the text contained in the main raw bruker structure into dictionaries.
  • bruker2nifti.converter.py Facade to collect users preferences on the conversion and accessing the core methods for the conversion (scan_to_struct, write_struct). Its main method, self.convert(), browses the study folder and apply convert_a_scan to all the scans contained. Results are saved in a folder structure homologous to bruker study with the files converted to nifti.
  • The folder parsers contains some parsers that can be used to access the method directly from command line.

Go to the API.