Пример #1
0
 def test_one_division(self):
     assembly = np.random.rand(100, 3)
     assembly = NeuroidAssembly(
         assembly,
         coords={'neuroid': list(range(len(assembly))), 'division_coord': list(range(assembly.shape[1]))},
         dims=['neuroid', 'division_coord'])
     transformation = CartesianProduct(dividers=['division_coord'])
     placeholder = self.MetricPlaceholder()
     transformation(assembly, apply=placeholder)
     assert len(assembly['division_coord']) == len(placeholder.assemblies)
     targets = [assembly.sel(division_coord=i) for i in assembly['division_coord'].values]
     for target in targets:
         match = any([actual == target] for actual in placeholder.assemblies)
         assert match, "expected divided assembly not found: {target}"
Пример #2
0
 def __init__(self, identifier):
     self._logger = logging.getLogger(fullname(self))
     self._identifier = identifier
     assembly = LazyLoad(self._load_assembly)
     self._target_assembly = assembly
     regression = linear_regression(xarray_kwargs=dict(
         stimulus_coord='word_id', neuroid_coord='subject_id'))
     correlation = pearsonr_correlation(xarray_kwargs=dict(
         correlation_coord='word_id', neuroid_coord='subject_id'))
     self._metric = CrossRegressedCorrelation(
         regression=regression,
         correlation=correlation,
         crossvalidation_kwargs=dict(splits=5,
                                     kfold=True,
                                     split_coord='word_id',
                                     stratification_coord='sentence_id'))
     self._cross = CartesianProduct(dividers=['subject_id'])
     self._ceiler = self.ManySubjectExtrapolationCeiling(
         subject_column='subject_id')
Пример #3
0
    def test_no_expand_raw_level(self):
        assembly = np.random.rand(3, 100)
        assembly = NeuroidAssembly(
            assembly,
            coords={'neuroid': list(range(assembly.shape[1])), 'division_coord': list(range(assembly.shape[0]))},
            dims=['division_coord', 'neuroid'])
        transformation = CartesianProduct(dividers=['division_coord'])

        class RawMetricPlaceholder(Metric):
            def __call__(self, assembly, *args, **kwargs):
                result = Score([assembly.values[0]], dims=['dim'])
                raw = result.copy()
                raw['dim_id'] = 'dim', [assembly.values[1]]
                raw['division_coord'] = 'dim', [assembly.values[2]]
                result.attrs['raw'] = raw
                return result

        metric = RawMetricPlaceholder()
        result = transformation(assembly, apply=metric)
        assert hasattr(result, 'raw')
        assert 'division_coord' not in result.raw  # no dimension
        assert hasattr(result.raw, 'division_coord')  # but a level
Пример #4
0
 def __init__(self, identifier, metric):
     super(_Fedorenko2016V3SubjectWise,
           self).__init__(identifier=identifier, metric=metric)
     self._ceiler.extrapolation_dimension = 'subject_UID'
     self._cross = CartesianProduct(dividers=['subject_UID'])
Пример #5
0
 def __init__(self, **kwargs):
     super(_PereiraSubjectWise, self).__init__(**kwargs)
     self._cross = CartesianProduct(dividers=['experiment', 'atlas', 'subject'])
     self._ceiler = self.PereiraSubjectWiseExtrapolationCeiling(
         extrapolation_dimension='subject', subject_column='subject', num_bootstraps=self._ceiler.num_bootstraps)
Пример #6
0
 def __init__(self, bold_shift=4):
     assemblies = self._load_rdms(bold_shift_seconds=bold_shift)
     assemblies = {story: rdm for story, rdm in assemblies.items() if story != 'Elvis'}
     self._target_assemblies = assemblies
     self._metric = RDMSimilarityCrossValidated()
     self._cross_region = CartesianProduct(dividers=['region'])