From f9a3d3a6573eae6f7aaa6666a4bb4e452598947c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Cl=C3=A9net?= Date: Wed, 4 Oct 2023 17:13:15 +0200 Subject: [PATCH] [ENH] A class to parse task data --- narps_open/data/task.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 narps_open/data/task.py diff --git a/narps_open/data/task.py b/narps_open/data/task.py new file mode 100644 index 00000000..58b192bd --- /dev/null +++ b/narps_open/data/task.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +# coding: utf-8 + +""" A mdoule to parse task data from NARPS for the narps_open package """ + +from os.path import join +from json import load + +from narps_open.utils.configuration import Configuration +from narps_open.utils.singleton import SingletonMeta + +class TaskInformation(dict, metaclass=SingletonMeta): + """ This class allows to access information about the task performed in NARPS """ + + def __init__(self): + super().__init__() + + # Load information from the task-MGT_bold.json file + file_name = join(Configuration()['directories']['dataset'], 'task-MGT_bold.json') + self.update(load(file)) + + # Compute derived information + self['NumberOfSlices'] = len(self['SliceTiming']) + self['AcquisitionTime'] = self['RepetitionTime'] / self['NumberOfSlices'] + self['TotalReadoutTime'] = self['NumberOfSlices'] * self['EffectiveEchoSpacing']