How to use the niworkflows.NIWORKFLOWS_LOG function in niworkflows

To help you get started, we’ve selected a few niworkflows 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 poldracklab / niworkflows / niworkflows / data / utils.py View on Github external
"""

    dataset_folder = dataset_name if not dataset_prefix \
        else '%s%s' % (dataset_prefix, dataset_name)
    default_paths = default_paths or ''
    paths = [p / dataset_folder for p in _get_data_path(data_dir)]
    all_paths = [Path(p) / dataset_folder
                 for p in default_paths.split(os.pathsep)] + paths

    # Check if the dataset folder exists somewhere and is not empty
    for path in all_paths:
        if path.is_dir() and list(path.iterdir()):
            if verbose > 1:
                NIWORKFLOWS_LOG.info(
                    'Dataset "%s" already cached in %s', dataset_name, path)
            return path, True

    for path in paths:
        if verbose > 0:
            NIWORKFLOWS_LOG.info(
                'Dataset "%s" not cached, downloading to %s', dataset_name, path)
        path.mkdir(parents=True, exist_ok=True)
        return path, False
github poldracklab / niworkflows / niworkflows / data / utils.py View on Github external
default_paths = default_paths or ''
    paths = [p / dataset_folder for p in _get_data_path(data_dir)]
    all_paths = [Path(p) / dataset_folder
                 for p in default_paths.split(os.pathsep)] + paths

    # Check if the dataset folder exists somewhere and is not empty
    for path in all_paths:
        if path.is_dir() and list(path.iterdir()):
            if verbose > 1:
                NIWORKFLOWS_LOG.info(
                    'Dataset "%s" already cached in %s', dataset_name, path)
            return path, True

    for path in paths:
        if verbose > 0:
            NIWORKFLOWS_LOG.info(
                'Dataset "%s" not cached, downloading to %s', dataset_name, path)
        path.mkdir(parents=True, exist_ok=True)
        return path, False
github poldracklab / niworkflows / niworkflows / viz / utils.py View on Github external
def extract_svg(display_object, dpi=300, compress="auto"):
    """Remove the preamble of the svg files generated with nilearn."""
    image_svg = svg2str(display_object, dpi)
    if compress is True or compress == "auto":
        image_svg = svg_compress(image_svg, compress)
    image_svg = re.sub(' height="[0-9]+[a-z]*"', "", image_svg, count=1)
    image_svg = re.sub(' width="[0-9]+[a-z]*"', "", image_svg, count=1)
    image_svg = re.sub(
        " viewBox", ' preseveAspectRation="xMidYMid meet" viewBox', image_svg, count=1
    )
    start_tag = "
github poldracklab / niworkflows / niworkflows / interfaces / report_base.py View on Github external
def _generate_report(self):
        """Generates the visual report."""
        from niworkflows.viz.utils import plot_registration

        NIWORKFLOWS_LOG.info("Generating visual report")

        anat = load_img(self._anat_file)
        contour_nii = load_img(self._contour) if self._contour is not None else None

        if self._mask_file:
            anat = unmask(apply_mask(anat, self._mask_file), self._mask_file)
            mask_nii = load_img(self._mask_file)
        else:
            mask_nii = threshold_img(anat, 1e-3)

        n_cuts = 7
        if not self._mask_file and contour_nii:
            cuts = cuts_from_bbox(contour_nii, cuts=n_cuts)
        else:
            cuts = cuts_from_bbox(mask_nii, cuts=n_cuts)
github poldracklab / niworkflows / niworkflows / interfaces / mni.py View on Github external
def _get_settings(self):
        """
        Return any settings defined by the user, as well as any pre-defined
        settings files that exist for the image modalities to be registered.
        """
        # If user-defined settings exist...
        if isdefined(self.inputs.settings):
            # Note this in the log and return those settings.
            NIWORKFLOWS_LOG.info("User-defined settings, overriding defaults")
            return self.inputs.settings

        # Define a prefix for output files based on the modality of the moving image.
        filestart = "{}-mni_registration_{}_".format(
            self.inputs.moving.lower(), self.inputs.flavor
        )

        # Get a list of settings files that match the flavor.
        filenames = [
            i
            for i in pkgr.resource_listdir("niworkflows", "data")
            if i.startswith(filestart) and i.endswith(".json")
        ]
        # Return the settings files.
        return [
            pkgr.resource_filename("niworkflows.data", f) for f in sorted(filenames)
github poldracklab / niworkflows / niworkflows / interfaces / segmentation.py View on Github external
def _post_run_hook(self, runtime):
        outputs = self.aggregate_outputs(runtime=runtime)
        self._noise_components_file = os.path.join(
            outputs.out_dir, "classified_motion_ICs.txt"
        )

        NIWORKFLOWS_LOG.info("Generating report for ICA AROMA")

        return super(ICA_AROMARPT, self)._post_run_hook(runtime)