How to use the mriqc.MRIQC_LOG.warn function in mriqc

To help you get started, weā€™ve selected a few mriqc 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 / mriqc / mriqc / utils / mriqc_run.py View on Github external
# Check physical memory
    total_memory = opts.mem_gb
    if total_memory < 0:
        try:
            from psutil import virtual_memory
            total_memory = virtual_memory().total // (1024 ** 3) + 1
        except ImportError:
            MRIQC_LOG.warn('Total physical memory could not be estimated, using %d'
                           'GB as default', DEFAULT_MEM_GB)
            total_memory = DEFAULT_MEM_GB

    if total_memory > 0:
        av_procs = total_memory // 4
        if av_procs < 1:
            MRIQC_LOG.warn('Total physical memory is less than 4GB, memory allocation'
                           ' problems are likely to occur.')
            n_procs = 1
        elif n_procs > av_procs:
            n_procs = av_procs

    settings = {
        'bids_dir': bids_dir,
        'write_graph': opts.write_graph,
        'testing': opts.testing,
        'hmc_afni': opts.hmc_afni,
        'n_procs': n_procs,
        'ants_nthreads': opts.ants_nthreads,
        'output_dir': op.abspath(opts.output_dir),
        'work_dir': op.abspath(opts.work_dir),
        'verbose_reports': opts.verbose_reports or opts.testing
    }
github poldracklab / mriqc / mriqc / utils / mriqc_run.py View on Github external
'considered for preprocessing')
    g_afni.add_argument('--stop-idx', action='store', type=int,
                        help='Final volume in functional timeseries that should be '
                             'considered for preprocessing')
    g_afni.add_argument('--correct-slice-timing', action='store_true', default=False,
                        help='Perform slice timing correction')

    opts = parser.parse_args()

    # Build settings dict
    bids_dir = op.abspath(opts.bids_dir)

    # Number of processes
    n_procs = 0
    if opts.nthreads is not None:
        MRIQC_LOG.warn('Option --nthreads has been deprecated in mriqc 0.8.8. '
                       'Please use --n_procs instead.')
        n_procs = opts.nthreads
    if opts.n_procs is not None:
        n_procs = opts.n_procs

    # Check physical memory
    total_memory = opts.mem_gb
    if total_memory < 0:
        try:
            from psutil import virtual_memory
            total_memory = virtual_memory().total // (1024 ** 3) + 1
        except ImportError:
            MRIQC_LOG.warn('Total physical memory could not be estimated, using %d'
                           'GB as default', DEFAULT_MEM_GB)
            total_memory = DEFAULT_MEM_GB
github poldracklab / mriqc / mriqc / utils / mriqc_run.py View on Github external
n_procs = 0
    if opts.nthreads is not None:
        MRIQC_LOG.warn('Option --nthreads has been deprecated in mriqc 0.8.8. '
                       'Please use --n_procs instead.')
        n_procs = opts.nthreads
    if opts.n_procs is not None:
        n_procs = opts.n_procs

    # Check physical memory
    total_memory = opts.mem_gb
    if total_memory < 0:
        try:
            from psutil import virtual_memory
            total_memory = virtual_memory().total // (1024 ** 3) + 1
        except ImportError:
            MRIQC_LOG.warn('Total physical memory could not be estimated, using %d'
                           'GB as default', DEFAULT_MEM_GB)
            total_memory = DEFAULT_MEM_GB

    if total_memory > 0:
        av_procs = total_memory // 4
        if av_procs < 1:
            MRIQC_LOG.warn('Total physical memory is less than 4GB, memory allocation'
                           ' problems are likely to occur.')
            n_procs = 1
        elif n_procs > av_procs:
            n_procs = av_procs

    settings = {
        'bids_dir': bids_dir,
        'write_graph': opts.write_graph,
        'testing': opts.testing,
github poldracklab / mriqc / mriqc / utils / mriqc_run.py View on Github external
if settings['n_procs'] > 1:
            plugin_settings['plugin'] = 'MultiProc'
            plugin_settings['plugin_args'] = {'n_procs': settings['n_procs']}

    MRIQC_LOG.info(
        'Running MRIQC-%s (analysis_level=%s, participant_label=%s)\n\tSettings=%s',
        __version__, opts.analysis_level, opts.participant_label, settings)

    # Set up participant level
    if opts.analysis_level == 'participant':
        for qctype in opts.data_type:
            ms_func = getattr(mwc, 'ms_' + qctype)
            workflow = ms_func(subject_id=opts.participant_label, session_id=opts.session_id,
                               run_id=opts.run_id, settings=settings)
            if workflow is None:
                MRIQC_LOG.warn(
                    '%s QC workflow - no scans were found for the given inputs',
                    'Anatomical' if qctype[:4] == 'anat' else 'Functional')
                continue

            workflow.base_dir = settings['work_dir']
            if settings.get('write_graph', False):
                workflow.write_graph()

            if not opts.dry_run:
                workflow.run(**plugin_settings)

    # Set up group level
    if opts.analysis_level == 'group' or opts.participant_label is None:
        from glob import glob
        from mriqc.reports import group_html
        from mriqc.utils.misc import generate_csv
github poldracklab / mriqc / mriqc / bin / mriqc_run.py View on Github external
'considered for preprocessing')
    g_afni.add_argument('--stop-idx', action='store', type=int,
                        help='Final volume in functional timeseries that should be '
                             'considered for preprocessing')
    g_afni.add_argument('--correct-slice-timing', action='store_true', default=False,
                        help='Perform slice timing correction')

    opts = parser.parse_args()

    # Build settings dict
    bids_dir = op.abspath(opts.bids_dir)

    # Number of processes
    n_procs = 0
    if opts.nthreads is not None:
        MRIQC_LOG.warn('Option --nthreads has been deprecated in mriqc 0.8.8. '
                       'Please use --n_procs instead.')
        n_procs = opts.nthreads
    else:
        n_procs = opts.n_procs

    settings = {
        'bids_dir': bids_dir,
        'write_graph': opts.write_graph,
        'testing': opts.testing,
        'hmc_afni': opts.hmc_afni,
        'hmc_fsl': opts.hmc_fsl,
        'fft_spikes_detector': opts.fft_spikes_detector,
        'n_procs': n_procs,
        'ants_nthreads': opts.ants_nthreads,
        'output_dir': op.abspath(opts.output_dir),
        'work_dir': op.abspath(opts.work_dir),
github poldracklab / mriqc / mriqc / bin / mriqc_run.py View on Github external
# Set up group level
    if 'group' in analysis_levels:
        from mriqc.reports import group_html
        from mriqc.utils.misc import generate_csv, generate_pred

        reports_dir = check_folder(op.join(settings['output_dir'], 'reports'))
        derivatives_dir = op.join(settings['output_dir'], 'derivatives')

        n_group_reports = 0
        for mod in modalities:
            dataframe, out_csv = generate_csv(derivatives_dir,
                                              settings['output_dir'], mod)

            # If there are no iqm.json files, nothing to do.
            if dataframe is None:
                MRIQC_LOG.warn(
                    'No IQM-JSON files were found for the %s data type in %s. The group-level '
                    'report was not generated.', mod, derivatives_dir)
                continue

            MRIQC_LOG.info('Summary CSV table for the %s data generated (%s)', mod, out_csv)

            # out_pred = generate_pred(derivatives_dir, settings['output_dir'], mod)
            # if out_pred is not None:
            #     MRIQC_LOG.info('Predicted QA CSV table for the %s data generated (%s)',
            #                    mod, out_pred)

            out_html = op.join(reports_dir, mod + '_group.html')
            group_html(out_csv, mod,
                       csv_failed=op.join(settings['output_dir'], 'failed_' + mod + '.csv'),
                       out_file=out_html)
            MRIQC_LOG.info('Group-%s report generated (%s)', mod, out_html)
github poldracklab / mriqc / mriqc / utils / mriqc_run.py View on Github external
# Set up group level
    if opts.analysis_level == 'group' or opts.participant_label is None:
        from glob import glob
        from mriqc.reports import group_html
        from mriqc.utils.misc import generate_csv

        reports_dir = check_folder(op.join(settings['output_dir'], 'reports'))

        derivatives_dir = op.join(settings['output_dir'], 'derivatives')
        for qctype in opts.data_type:
            qcjson = op.join(derivatives_dir, '{}*.json'.format(qctype[:4]))

            # If there are no iqm.json files, nothing to do.
            if not qcjson:
                MRIQC_LOG.warn(
                    'Generating group-level report for the "%s" data type - '
                    'no IQM-JSON files were found in "%s"', qctype, derivatives_dir)
                continue

            # If some were found, generate the CSV file and group report
            out_csv = op.join(settings['output_dir'], qctype[:4] + 'MRIQC.csv')
            out_html = op.join(reports_dir, qctype[:4] + '_group.html')
            generate_csv(glob(qcjson), out_csv)
            MRIQC_LOG.info('Summary CSV table has been written to %s', out_csv)
            group_html(out_csv, qctype, out_file=out_html)
            MRIQC_LOG.info('Group HTML report has been written to %s', out_html)