How to use the fastr.config function in fastr

To help you get started, we’ve selected a few fastr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MStarmans91 / WORC / WORC / classification / SearchCV.py View on Github external
regressors = cc.list_regression_classifiers()
        isclassifier =\
            not any(clf in regressors for clf in self.param_distributions['classifiers'])

        print('----', isclassifier, self.param_distributions['classifiers'], '----')
        cv = check_cv(self.cv, y, classifier=isclassifier)

        X, y, groups = indexable(X, y, groups)
        n_splits = cv.get_n_splits(X, y, groups)
        if self.verbose > 0 and isinstance(parameter_iterable, Sized):
            n_candidates = len(parameter_iterable)
            print(f"Fitting {n_splits} folds for each of {n_candidates} candidates, totalling {n_candidates * n_splits} fits.")

        cv_iter = list(cv.split(X, y, groups))
        name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
        tempfolder = os.path.join(fastr.config.mounts['tmp'], 'GS', name)
        if not os.path.exists(tempfolder):
            os.makedirs(tempfolder)

        # Draw parameter sample
        for num, parameters in enumerate(parameter_iterable):
            parameter_sample = parameters
            break

        # Preprocess features if required
        if 'FeatPreProcess' in parameter_sample:
            if parameter_sample['FeatPreProcess'] == 'True':
                print("Preprocessing features.")
                feature_values = np.asarray([x[0] for x in X])
                feature_labels = np.asarray([x[1] for x in X])
                preprocessor = Preprocessor(verbose=False)
                preprocessor.fit(feature_values, feature_labels=feature_labels[0, :])
github MStarmans91 / WORC / WORC / WORC.py View on Github external
# Draw and execute nwtwork
        try:
            self.network.draw(file_path=self.network.id + '.svg', draw_dimensions=True)
        except graphviz.backend.ExecutableNotFound:
            print('[WORC WARNING] Graphviz executable not found: not drawing network diagram. Make sure the Graphviz executables are on your systems PATH.')

        if DebugDetector().do_detection():
            print("Source Data:")
            for k in self.source_data.keys():
                print(f"\t {k}: {self.source_data[k]}.")
            print("\n Sink Data:")
            for k in self.sink_data.keys():
                print(f"\t {k}: {self.sink_data[k]}.")

            # When debugging, set the tempdir to the default of fastr + name
            self.fastr_tmpdir = os.path.join(fastr.config.mounts['tmp'],
                                             self.name)

        self.network.execute(self.source_data, self.sink_data, execution_plugin=self.fastr_plugin, tmpdir=self.fastr_tmpdir)
github MStarmans91 / WORC / WORC / WORC.py View on Github external
self._add_evaluation = False
        self.TrainTest = False

        # Memory settings for all fastr nodes
        self.fastr_memory_parameters = dict()
        self.fastr_memory_parameters['FeatureCalculator'] = '14G'
        self.fastr_memory_parameters['Classification'] = '12G'
        self.fastr_memory_parameters['WORCCastConvert'] = '4G'
        self.fastr_memory_parameters['Preprocessing'] = '4G'
        self.fastr_memory_parameters['Elastix'] = '4G'
        self.fastr_memory_parameters['Transformix'] = '4G'
        self.fastr_memory_parameters['Segmentix'] = '6G'
        self.fastr_memory_parameters['ComBat'] = '12G'

        if DebugDetector().do_detection():
            print(fastr.config)
github MStarmans91 / WORC / WORC / tools / Elastix.py View on Github external
if not self.MovingImage:
            message = "You need to supply a moving image for registration."
            raise WORCexceptions.WORCNotImplementedError(message)

        if len(self.ParameterMaps) == 0:
            message = "You need to supply at leat one parameter map for registration."
            raise WORCexceptions.WORCNotImplementedError(message)

        # Set moving and fixed image sources
        self.source_data = dict()
        self.source_data['FixedImage'] = self.FixedImage
        self.source_data['MovingImage'] = self.MovingImage

        # Create a temporary directory to use
        tempdir = os.path.join(fastr.config.mounts['tmp'], 'WORC_Elastix')
        if not os.path.exists(tempdir):
            os.makedirs(tempdir)

        # Set the parameter map sources
        if type(self.ParameterMaps) is list:
            # Files, thus just provide them to the elastix node
            self.source_data['ParameterMaps'] = self.ParameterMaps
        else:
            # Use SimpleTransformix to save the maps and add them
            SimpleElastix = sitk.SimpleElastix()
            self.source_data['ParameterMaps'] = list()
            for num, f in enumerate(self.ParameterMaps):
                filename = ('ParameterMap{}.txt').format(str(num))
                fname = os.path.join(tempdir, filename)
                SimpleElastix.WriteParameterFile(f, fname)
                sourcename = 'vfs://tmp/WORC_Elastix/' + filename

fastr

Workflow creation and batch execution environment.

Apache-2.0
Latest version published 6 months ago

Package Health Score

51 / 100
Full package analysis