Exemplo n.º 1
0
 def args(self):
     for fmri, meta in zip(self.config.get_bids('func'),
                           self.config.get_bids('func_metadata')):
         # set ts parameters
         self.kwargs['fmritcs'] = fmri
         self.kwargs['fmriname'] = get_fmriname(fmri)
         self.kwargs['fmriscout'] = None  # not implemented
         if self.kwargs['dcmethod'] == 'TOPUP':
             self.kwargs['seunwarpdir'] = ijk_to_xyz(
                 meta['PhaseEncodingDirection'])
             self.kwargs['sephasepos'], self.kwargs['sephaseneg'] = \
                 self._get_intended_sefmaps()
         else:
             self.kwargs['sephasepos'] = self.kwargs['sephaseneg'] = None
         # None to NONE
         kw = {
             k: (v if v is not None else "NONE")
             for k, v in self.kwargs.items()
         }
         yield self.spec.format(**kw)
Exemplo n.º 2
0
    def __init__(self, bids_data, output_directory):
        """
        Specification to run pipeline on a single subject session.
        :param bids_data: yielded spec from read_bids_dataset
        :param output_directory: output directory for pipeline
        """

        # input bids data struct
        self.bids_data = bids_data
        # @ parameters read from bids @ #
        self.t1w = self.bids_data['t1w']
        self.t1samplespacing = get_realdwelltime(
            self.bids_data['t1w_metadata'])

        if 'T2w' in self.bids_data['types']:
            self.useT2 = 'true'
            self.t2w = self.bids_data['t2w']
            self.t2samplespacing = get_realdwelltime(
                self.bids_data['t2w_metadata'])
        else:
            self.useT2 = 'false'
            self.t2w = []
            self.t2samplespacing = None

        # distortion correction method: TOPUP, FIELDMAP, or NONE, inferred
        # from files, defaults to spin echo (topup) if both field maps exist
        self.unwarpdir = get_readoutdir(self.bids_data['t1w_metadata'])
        if 'epi' in self.bids_data['types']:
            self.dcmethod = 'TOPUP'
            # spin echo field map spacing @TODO read during volume per fmap?
            self.echospacing = self.bids_data['fmap_metadata']['positive'][0][
                'EffectiveEchoSpacing']
            self.echospacing = ('%.12f' % self.echospacing).rstrip('0')
            # distortion correction phase encoding direction
            if self.bids_data['func']:
                self.seunwarpdir = ijk_to_xyz(
                    self.bids_data['func_metadata']['PhaseEncodingDirection'])
            else:
                # if no functional data is provided, use positive spin echo
                self.seunwarpdir = ijk_to_xyz(
                    self.bids_data['fmap_metadata']['positive'][0]
                    ['PhaseEncodingDirection'])

            # set unused fmap parameters to none
            self.fmapmag = self.fmapphase = self.fmapgeneralelectric = \
                self.echodiff = self.gdcoeffs = None

        elif 'magnitude' in self.bids_data['types']:
            self.dcmethod = 'FIELDMAP'
            # gradient field map delta TE
            self.echodiff = None  # @TODO

            # set unused spin echo parameters to none
            self.seunwarpdir = None

        else:
            # all distortion correction parameters set to none
            self.fmapmag = self.fmapphase = self.fmapgeneralelectric = \
                self.echodiff = self.gdcoeffs = self.dcmethod = \
                self.seunwarpdir = self.echospacing = None

        if not hasattr(self, 'fmribfcmethod'):
            self.fmribfcmethod = None  # this parameter has not been validated

        # dwi parameters
        if 'dwi' in self.bids_data['types']:
            pass

        # @TODO handle bids formatted physio data
        self.physio = None

        # intermediate template defaults
        self.usestudytemplate = "false"
        self.studytemplate = None
        self.studytemplatebrain = None

        # @ output files @ #
        self.path = os.path.join(output_directory, 'files')
        self.logs = os.path.join(output_directory, 'logs')
        self.subject = self.bids_data['subject']
        self.session = self.bids_data['session']

        # Exec summ doesn't need this anymore. KJS 11/6/18
        #deriv_root = self.path.split('/')[:-3]
        #self.deriv = '/'.join(deriv_root)

        # @ input files @ #
        session_root = '/'.join(self.t1w[0].split('/')[:-2])
        self.unproc = os.path.join(session_root, 'func')

        bids_input_root = '/'.join(session_root.split('/')[:-2])
        self.sourcedata_root = os.path.join(bids_input_root, 'sourcedata')

        # print command for HCP
        self.printcom = ''