Beispiel #1
0
class SimulatorAdapterModel(ViewModel, Simulator):
    @property
    def linked_has_traits(self):
        return Simulator

    connectivity = DataTypeGidAttr(linked_datatype=Connectivity,
                                   required=Simulator.connectivity.required,
                                   label=Simulator.connectivity.label,
                                   doc=Simulator.connectivity.doc)

    surface = Attr(field_type=CortexViewModel,
                   label=Simulator.surface.label,
                   default=Simulator.surface.default,
                   required=Simulator.surface.required,
                   doc=Simulator.surface.doc)

    stimulus = DataTypeGidAttr(linked_datatype=SpatioTemporalPattern,
                               label=Simulator.stimulus.label,
                               default=Simulator.stimulus.default,
                               required=Simulator.stimulus.required,
                               doc=Simulator.stimulus.doc)

    history_gid = DataTypeGidAttr(linked_datatype=SimulationHistory,
                                  required=False)

    monitors = List(of=MonitorViewModel,
                    label=Simulator.monitors.label,
                    default=(TemporalAverageViewModel(), ),
                    doc=Simulator.monitors.doc)
Beispiel #2
0
class CortexViewModel(ViewModel, Cortex):

    @property
    def linked_has_traits(self):
        return Cortex

    surface_gid = DataTypeGidAttr(
        linked_datatype=CorticalSurface,
        label=Simulator.surface.label,
        default=Simulator.surface.default,
        required=Simulator.surface.required,
        doc=Simulator.surface.doc
    )

    local_connectivity = DataTypeGidAttr(
        linked_datatype=LocalConnectivity,
        required=Cortex.local_connectivity.required,
        label=Cortex.local_connectivity.label,
        doc=Cortex.local_connectivity.doc
    )

    region_mapping_data = DataTypeGidAttr(
        linked_datatype=RegionMapping,
        label=Cortex.region_mapping_data.label,
        doc=Cortex.region_mapping_data.doc
    )
class ProjectionMatrixImporterModel(UploaderViewModel):
    projection_file = Str(
        label='Projection matrix file (.mat or .npy format)',
        doc='Expected a file containing projection matrix (one vector of length '
            'number of surface vertices nd values in the sensors range).'
    )

    dataset_name = Attr(
        field_type=str,
        required=False,
        default=DEFAULT_DATASET_NAME,
        label='Matlab dataset name',
        doc='Name of the MATLAB dataset where data is stored. Required only for .mat files'
    )

    surface = DataTypeGidAttr(
        linked_datatype=Surface,
        label='Brain Cortical Surface',
        doc='The Brain Surface used by the uploaded projection matrix.'
    )

    sensors = DataTypeGidAttr(
        linked_datatype=Sensors,
        label='Sensors',
        doc='The Sensors used in for current projection.'
    )
Beispiel #4
0
class TimeSeriesVolumeVisualiserModel(ViewModel):
    time_series = DataTypeGidAttr(linked_datatype=TimeSeries,
                                  label='Time Series')

    background = DataTypeGidAttr(linked_datatype=StructuralMRI,
                                 required=False,
                                 label='Background T1')
Beispiel #5
0
class SimulatorAdapterModel(ViewModel, Simulator):
    connectivity = DataTypeGidAttr(
        linked_datatype=Connectivity,
        required=Simulator.connectivity.required,
        label=Simulator.connectivity.label,
        doc=Simulator.connectivity.doc
    )

    surface = Attr(
        field_type=CortexViewModel,
        label=Simulator.surface.label,
        default=Simulator.surface.default,
        required=Simulator.surface.required,
        doc=Simulator.surface.doc
    )

    stimulus = DataTypeGidAttr(
        linked_datatype=SpatioTemporalPattern,
        label=Simulator.stimulus.label,
        default=Simulator.stimulus.default,
        required=Simulator.stimulus.required,
        doc=Simulator.stimulus.doc
    )

    history_gid = DataTypeGidAttr(
        linked_datatype=SimulationHistory,
        required=False
    )
Beispiel #6
0
    def get_filtered_datatypes(self, dt_module, dt_class, filters,
                               has_all_option, has_none_option):
        """
        Given the name from the input tree, the dataType required and a number of
        filters, return the available dataType that satisfy the conditions imposed.
        """
        index_class = getattr(sys.modules[dt_module], dt_class)()
        filters_dict = json.loads(filters)

        fields = []
        operations = []
        values = []

        for idx in range(len(filters_dict['fields'])):
            fields.append(filters_dict['fields'][idx])
            operations.append(filters_dict['operations'][idx])
            values.append(filters_dict['values'][idx])

        filter = FilterChain(fields=fields,
                             operations=operations,
                             values=values)
        project = common.get_current_project()

        form = Form(project_id=project.id, draw_ranges=True)
        data_type_gid_attr = DataTypeGidAttr(
            linked_datatype=REGISTRY.get_datatype_for_index(index_class))
        data_type_gid_attr.required = not string2bool(has_none_option)

        select_field = TraitDataTypeSelectField(
            data_type_gid_attr,
            form,
            conditions=filter,
            has_all_option=string2bool(has_all_option))

        return {'options': select_field.options()}
Beispiel #7
0
    def get_filtered_datatypes(self, dt_module, dt_class, filters,
                               has_all_option, has_none_option):
        """
        Given the name from the input tree, the dataType required and a number of
        filters, return the available dataType that satisfy the conditions imposed.
        """
        index_class = getattr(sys.modules[dt_module], dt_class)()
        filters_dict = json.loads(filters)

        for idx in range(len(filters_dict['fields'])):
            if filters_dict['values'][idx] in ['True', 'False']:
                filters_dict['values'][idx] = string2bool(
                    filters_dict['values'][idx])

        filter = FilterChain(fields=filters_dict['fields'],
                             operations=filters_dict['operations'],
                             values=filters_dict['values'])
        project = common.get_current_project()

        data_type_gid_attr = DataTypeGidAttr(
            linked_datatype=REGISTRY.get_datatype_for_index(index_class))
        data_type_gid_attr.required = not string2bool(has_none_option)

        select_field = TraitDataTypeSelectField(
            data_type_gid_attr,
            conditions=filter,
            has_all_option=string2bool(has_all_option))
        self.algorithm_service.fill_selectfield_with_datatypes(
            select_field, project.id)

        return {'options': select_field.options()}
class RegionVolumeMappingVisualiserModel(BaseVolumeVisualizerModel):
    region_mapping_volume = DataTypeGidAttr(
        linked_datatype=RegionVolumeMapping, label='Region mapping')

    connectivity_measure = DataTypeGidAttr(linked_datatype=ConnectivityMeasure,
                                           required=False,
                                           label='Connectivity measure',
                                           doc='A connectivity measure')
Beispiel #9
0
class SimulatorAdapterModel(ViewModel, Simulator):

    @property
    def linked_has_traits(self):
        return Simulator

    connectivity = DataTypeGidAttr(
        linked_datatype=Connectivity,
        required=Simulator.connectivity.required,
        label=Simulator.connectivity.label,
        doc=Simulator.connectivity.doc
    )

    surface = Attr(
        field_type=CortexViewModel,
        label=Simulator.surface.label,
        default=Simulator.surface.default,
        required=Simulator.surface.required,
        doc=Simulator.surface.doc
    )

    stimulus = DataTypeGidAttr(
        linked_datatype=SpatioTemporalPattern,
        label=Simulator.stimulus.label,
        default=Simulator.stimulus.default,
        required=Simulator.stimulus.required,
        doc=Simulator.stimulus.doc
    )

    history_gid = DataTypeGidAttr(
        linked_datatype=SimulationHistory,
        required=False
    )

    integrator = Attr(
        field_type=IntegratorViewModel,
        label=Simulator.integrator.label,
        default=HeunDeterministicViewModel(),
        required=Simulator.integrator.required,
        doc=Simulator.integrator.doc
    )

    monitors = List(
        of=MonitorViewModel,
        label=Simulator.monitors.label,
        default=(TemporalAverageViewModel(),),
        doc=Simulator.monitors.doc
    )

    def __init__(self):
        super(SimulatorAdapterModel, self).__init__()
        self.coupling = type(self.coupling)()
        self.model = type(self.model)()
        self.integrator = type(self.integrator)()
        self.monitors = (type(self.monitors[0])(),)
Beispiel #10
0
class BrainViewerModel(ViewModel):
    time_series = DataTypeGidAttr(linked_datatype=TimeSeries,
                                  label='Time Series (Region or Surface)')

    shell_surface = DataTypeGidAttr(
        linked_datatype=Surface,
        required=False,
        label='Shell Surface',
        doc=
        'Surface to be displayed semi-transparently as overlay, for visual navigation purposes only.'
    )
Beispiel #11
0
class TractViewerModel(ViewModel):
    tracts = DataTypeGidAttr(linked_datatype=Tracts,
                             label='White matter tracts')

    shell_surface = DataTypeGidAttr(
        linked_datatype=Surface,
        required=False,
        label='Shell Surface',
        doc=
        'Surface to be displayed semi-transparently, for visual purposes only.'
    )
Beispiel #12
0
class iEEGViewModel(ProjectionViewModel, iEEG):
    projection = DataTypeGidAttr(linked_datatype=ProjectionSurfaceSEEG,
                                 label=iEEG.projection.label,
                                 doc=iEEG.projection.doc)

    sensors = DataTypeGidAttr(linked_datatype=SensorsInternal,
                              label=iEEG.sensors.label,
                              doc=iEEG.sensors.doc)

    @property
    def linked_has_traits(self):
        return iEEG
Beispiel #13
0
class MEGViewModel(ProjectionViewModel, MEG):
    projection = DataTypeGidAttr(linked_datatype=ProjectionSurfaceMEG,
                                 label=MEG.projection.label,
                                 doc=MEG.projection.doc)

    sensors = DataTypeGidAttr(linked_datatype=SensorsMEG,
                              label=MEG.sensors.label,
                              doc=MEG.sensors.doc)

    @property
    def linked_has_traits(self):
        return MEG
class VolumeVisualizerModel(BaseVolumeVisualizerModel):
    measure = DataTypeGidAttr(linked_datatype=DataTypeMatrix,
                              label='Measure',
                              doc='A measure to view on anatomy')

    region_mapping_volume = DataTypeGidAttr(
        linked_datatype=RegionVolumeMapping,
        required=False,
        label='Region mapping')

    data_slice = Attr(field_type=str,
                      required=False,
                      label='slice indices in numpy syntax')
Beispiel #15
0
class ConnectivityViewerModel(ViewModel):
    """
    Attributes meaning:
        connectivity: GID towards the `Connectivity` object which will be displayed
        surface_data: if provided, it is displayed as a shadow to give an idea of the connectivity position
                      relative to the full brain cortical surface
        colors: used to establish a colormap for the nodes displayed in 2D Connectivity viewers
        rays: used to establish the size of the spheres representing each node in 3D Nodes viewer
        step: a threshold applied to the 2D Connectivity Viewers to differentiate 2 types of nodes the ones
              with a value greater that this will be displayed as red discs, instead of yellow
    """

    connectivity = DataTypeGidAttr(
        linked_datatype=Connectivity,
        label='Connectivity Matrix'
    )

    surface_data = DataTypeGidAttr(
        linked_datatype=Surface,
        required=False,
        label='Brain Surface',
        doc='The Brain Surface is used to give you an idea of the connectivity '
            'position relative to the full brain cortical surface. This surface'
            ' will be displayed as a shadow (only used in 3D Edges tab).'
    )

    step = Attr(
        field_type=float,
        required=False,
        label='Color Threshold',
        doc='All nodes with a value greater or equal (>=) than this threshold will be '
            'displayed as red discs, otherwise (<) they will be yellow. (This applies to '
            '2D Connectivity tabs and the threshold will depend on the metric used to set '
            'the Node Color)'
    )

    colors = DataTypeGidAttr(
        linked_datatype=ConnectivityMeasure,
        required=False,
        label='Node Colors',
        doc='A ConnectivityMeasure DataType that establishes a colormap for the nodes displayed '
            'in the 2D Connectivity tabs.'
    )

    rays = DataTypeGidAttr(
        linked_datatype=ConnectivityMeasure,
        required=False,
        label='Shapes Dimensions',
        doc='A ConnectivityMeasure datatype used to establish the size of the spheres representing each node. '
            '(It only applies to 3D Nodes tab).'
    )
Beispiel #16
0
class EegMonitorModel(ViewModel):
    input_data = DataTypeGidAttr(linked_datatype=TimeSeries,
                                 label='Input Data',
                                 doc='Time series to display.')

    data_2 = DataTypeGidAttr(linked_datatype=TimeSeries,
                             required=False,
                             label='Input Data 2',
                             doc='Time series to display.')

    data_3 = DataTypeGidAttr(linked_datatype=TimeSeries,
                             required=False,
                             label='Input Data 3',
                             doc='Time series to display.')
class CortexViewModel(ViewModel, Cortex):

    surface_gid = DataTypeGidAttr(linked_datatype=CorticalSurface)

    local_connectivity = DataTypeGidAttr(
        linked_datatype=LocalConnectivity,
        required=Cortex.local_connectivity.required,
        label=Cortex.local_connectivity.label,
        doc=Cortex.local_connectivity.doc)

    region_mapping_data = DataTypeGidAttr(
        linked_datatype=RegionMapping,
        label=Cortex.region_mapping_data.label,
        doc=Cortex.region_mapping_data.doc)
class RegionMappingImporterModel(UploaderViewModel):
    mapping_file = Str(
        label='Please upload region mapping file (txt, zip or bz2 format)',
        doc='Expected a text/zip/bz2 file containing region mapping values.')

    surface = DataTypeGidAttr(
        linked_datatype=Surface,
        label='Brain Surface',
        doc='The Brain Surface used by uploaded region mapping.')

    connectivity = DataTypeGidAttr(
        linked_datatype=Connectivity,
        label='Connectivity',
        required=True,
        doc='The Connectivity used by uploaded region mapping.')
Beispiel #19
0
class TimeseriesMetricsAdapterModel(ViewModel):
    time_series = DataTypeGidAttr(
        linked_datatype=TimeSeries,
        label="Time Series",
        required=True,
        doc="The TimeSeries for which the metric(s) will be computed.")

    algorithms = List(
        of=str,
        choices=tuple(ALGORITHMS.keys()),
        label='Selected metrics to be applied',
        doc=
        'The selected algorithms will all be applied on the input TimeSeries')

    start_point = Float(
        label="Start point (ms)",
        default=500.0,
        required=False,
        doc=""" The start point determines how many points of the TimeSeries will
        be discarded before computing the metric. By default it drops the
        first 500 ms.""")

    segment = Int(
        label="Segmentation factor",
        default=4,
        required=False,
        doc=
        """ Divide the input time-series into discrete equally sized sequences and
        use the last segment to compute the metric. It is only used when
        the start point is larger than the time-series length.""")
Beispiel #20
0
class CSVConnectivityImporterModel(UploaderViewModel):
    weights = Str(
        label='Weights file (csv)'
    )

    weights_delimiter = Str(
        choices=tuple(DELIMITER_OPTIONS.values()),
        default=tuple(DELIMITER_OPTIONS.values())[0],
        label='Field delimiter : '
    )

    tracts = Str(
        label='Tracts file (csv)'
    )

    tracts_delimiter = Str(
        choices=tuple(DELIMITER_OPTIONS.values()),
        default=tuple(DELIMITER_OPTIONS.values())[0],
        label='Field delimiter : '
    )

    input_data = DataTypeGidAttr(
        linked_datatype=Connectivity,
        label='Reference Connectivity Matrix (for node labels, 3d positions etc.)'
    )
Beispiel #21
0
class RegionMatTimeSeriesImporterModel(UploaderViewModel):
    data_file = Str(label='Please select file to import')

    dataset_name = Str(label='Matlab dataset name',
                       doc='Name of the MATLAB dataset where data is stored')

    structure_path = Str(
        required=False,
        default='',
        label='For nested structures enter the field path (separated by .)')

    transpose = Attr(
        field_type=bool,
        required=False,
        default=False,
        label='Transpose the array. Expected shape is (time, channel)')

    slice = Str(
        required=False,
        default='',
        label=
        'Slice of the array in numpy syntax. Expected shape is (time, channel)'
    )

    sampling_rate = Int(required=False,
                        default=100,
                        label='sampling rate (Hz)')

    start_time = Int(default=0, label='starting time (ms)')

    datatype = DataTypeGidAttr(linked_datatype=Connectivity,
                               label='Connectivity')
Beispiel #22
0
class MatrixVisualizerModel(ViewModel):
    datatype = DataTypeGidAttr(linked_datatype=DataTypeMatrix,
                               label='Array data type')

    slice = Attr(field_type=str,
                 required=False,
                 label='slice indices in numpy syntax')
Beispiel #23
0
class GIFTITimeSeriesImporterModel(UploaderViewModel):
    data_file = Str(label='Please select file to import (.gii)')

    surface = DataTypeGidAttr(
        linked_datatype=Surface,
        label='Brain Surface',
        doc='The Brain Surface used to generate imported TimeSeries.')
Beispiel #24
0
class ConnectivityCreatorModel(ViewModel):

    original_connectivity = DataTypeGidAttr(
        linked_datatype=Connectivity,
        default=None,
        label="Parent connectivity",
        required=True
    )

    new_weights = NArray(
        default=None,
        label="Weights json array",
        required=True,
        doc="""""")

    new_tracts = NArray(
        default=None,
        label="Tracts json array",
        required=True,
        doc="""""")

    interest_area_indexes = NArray(
        dtype=numpy.int,
        default=None,
        label="Indices of selected nodes as json array",
        required=True,
        doc="""""")

    is_branch = Attr(
        field_type=bool,
        label="Is it a branch",
        required=False,
        doc="""""")
Beispiel #25
0
class WaveletAdapterModel(ViewModel, ContinuousWaveletTransform):
    time_series = DataTypeGidAttr(
        linked_datatype=TimeSeries,
        label="Time Series",
        required=True,
        doc="""The timeseries to which the wavelet is to be applied."""
    )
class NodeComplexCoherenceModel(ViewModel, NodeComplexCoherence):
    time_series = DataTypeGidAttr(
        linked_datatype=TimeSeries,
        label="Time Series",
        required=True,
        doc="""The timeseries for which the CrossCoherence and ComplexCoherence is to be computed."""
    )
Beispiel #27
0
class ConnectivityAnnotationsViewModel(ViewModel):
    connectivity_index = DataTypeGidAttr(
        linked_datatype=Connectivity,
        required=False,
        label='Large Scale Connectivity Matrix')

    annotations_index = DataTypeGidAttr(
        linked_datatype=ConnectivityAnnotations, label='Ontology Annotations')

    region_mapping_index = DataTypeGidAttr(
        linked_datatype=RegionMapping,
        required=False,
        label='Region mapping',
        doc=
        'A region map to identify us the Cortical Surface to display,  as well as how the mapping '
        'from Connectivity to Cortex is done ')
Beispiel #28
0
class FCDAdapterModel(ViewModel):
    time_series = DataTypeGidAttr(
        linked_datatype=TimeSeriesRegion,
        label="Time Series",
        required=True,
        doc="""The time-series for which the fcd matrices are calculated.""")

    sw = Float(
        label="Sliding window length (ms)",
        default=120000,
        doc="""Length of the time window used to divided the time series.
        FCD matrix is calculated in the following way: the time series is divided in time window of fixed length and
        with an overlapping of fixed length. The data-points within each window, centered at time ti, are used to
        calculate FC(ti) as Pearson correlation. The ij element of the FCD matrix is calculated as the Pearson
        Correlation between FC(ti) and FC(tj) arranged in a vector.""")

    sp = Float(
        label="Spanning between two consecutive sliding window (ms)",
        default=2000,
        doc=
        """Spanning= (time windows length)-(overlapping between two consecutive time window). FCD matrix is
        calculated in the following way: the time series is divided in time window of fixed length and with an
        overlapping of fixed length. The data-points within each window, centered at time ti, are used to calculate
        FC(ti) as Pearson Correlation. The ij element of the FCD matrix is calculated as the Pearson correlation
        between FC(ti) and FC(tj) arranged in a vector""")
Beispiel #29
0
class CrossCorrelateAdapterModel(ViewModel, CrossCorrelate):
    time_series = DataTypeGidAttr(
        linked_datatype=TimeSeries,
        label="Time Series",
        required=True,
        doc="""The time-series for which the cross correlation sequences are calculated."""
    )
class NIFTIImporterModel(UploaderViewModel):
    data_file = Str(
        label='Please select file to import (gz or nii)'
    )

    apply_corrections = Attr(
        field_type=bool,
        required=False,
        label='Apply auto Corrections',
        doc='Check this when the NII mapping has values outside [-1..N-1]. '
            'All outside range will be set -1 (background).'
    )

    mappings_file = Str(
        required=False,
        label='Mapping File',
        doc='Fill this for Region Mappings, when the indices in the NII do not match '
            'the Connectivity [0..N-1] indices'
    )

    connectivity = DataTypeGidAttr(
        linked_datatype=Connectivity,
        required=False,
        label='Connectivity',
        doc='Optional Connectivity if the NII file is a volume2regions mapping'
    )