-
Notifications
You must be signed in to change notification settings - Fork 22
Examples
Sebastiano Ferraris edited this page Jul 25, 2017
·
24 revisions
Type
python parsers/bruker2nii -h
for help and see the options.
You can convert a study from the parsers without any installation, with
python parsers/bruker2nii -i path/to/bruker/study -o path/to/output/folder
To convert a scan, to modify the code or to call the code with an import within other python module it is recommended to install the python package as a library following the next instructions.
You can add the bruker2nifti folder in your PYTHONPATH, or you can install the converter as a library (next section more instructions on this).
To convert one of the test study, enter in an python or ipython session of a distribution with the required libraries installed the following lines:
import os
from bruker2nifti.converter import Bruker2Nifti
root_dir = '/path/to/bruker2nifti/repo'
pfo_study_in = os.path.join(root_dir, 'test_data', 'bru_banana')
pfo_study_out = '/path/to/some/existing/folder/where/conversion/will/happen'
# instantiate a converter - if you do not want to use the default study name in visu_pars set the study name here.
bru = Bruker2Nifti(pfo_study_in, pfo_study_out, study_name='banana')
# select the options (attributes) you may want to change - the one shown below are the default one:
bru.verbose = 2
bru.correct_slope = True
bru.get_acqp = False
bru.get_method = False
bru.get_reco = False
bru.nifti_version = 1
bru.qform_code = 1
bru.sform_code = 2
bru.save_human_readable = True
bru.save_b0_if_dwi = True
bru.correct_slope = False
# Check that the list of scans and the scans names automatically selected makes some sense:
print(bru.scans_list)
print(bru.list_new_name_each_scan)
print(bru.list_new_nifti_file_names)
# call the function convert, to convert the study:
bru.convert()