Example #1
0
        qc[key] = float(value)
    if isinstance(value, numpy.core.memmap):
        if value.dtype == numpy.single or value.dtype == numpy.double:
            qc[key] = float(value)
        elif value.dtype == numpy.int:
            qc[key] = int(value)
        else:
            raise ValueError("Unexpected value type '{0}:{1}'".format(key,
                                                                      value))
with open(scores_json, "w") as open_file:
    json.dump(qc, open_file, indent=4)

# Control FOV
mean_snap = os.path.join(subjectdir, "mean_epi.pdf")
figures.append(mean_snap)
fig = plot_mosaic(args.meanepi, title="Mean EPI")
fig.savefig(mean_snap, dpi=300)


# Control wrapping on template
mean_snap_norm = os.path.join(subjectdir, "mean_normalized_epi_masked.pdf")
figures.append(mean_snap_norm)
fig = plot_mosaic(args.wrappedmean,
                  title="Mean wrapped EPI",
                  overlay_mask=args.basemask)
fig.savefig(mean_snap_norm, dpi=300)
# compute overlapping score between template mask and mean mask
# load masks
subject_mask_data = nibabel.load(args.meanwrappedmask).get_data()
template_mask_data = nibabel.load(args.basemask).get_data()
Example #2
0
        "spm_funcnormalize_template": ["wau{}.nii", "pyscript_normalize.m"],
        "smoothing": ["pyscript_smooth.m", "swau{}.nii"],
    }
else:
    raise NotImplementedError("Can't reorganize the data.")
image_basename = os.path.basename(funcfile).split(".")[0]
for step_name, step_fnames in processing_struct.items():
    for basename in step_fnames:
        basename = basename.format(image_basename)
        srcpath = os.path.join(tmp_capsul, step_name, basename)
        if srcpath.endswith(".nii"):
            gzip_file(srcpath, prefix="", output_directory=outdir)
        else:
            if (step_name == "spm_funcnormalize_template") and (basename == "pyscript_normalize.m"):
                destpath = os.path.join(outdir, "pyscript_apply_normalize.m")
            elif step_name == "":
                destpath = os.path.join(logdir, "{0}_{1}".format(sid, basename))
            else:
                destpath = os.path.join(outdir, basename)
            shutil.move(srcpath, destpath)
shutil.rmtree(tmp_capsul)

"""
Create a snap to chack the registration result
"""
if args.template_mask is not None:
    snap = os.path.join(outdir, image_basename + ".pdf")
    image = os.path.join(outdir, "wmeanau{}.nii.gz".format(image_basename))
    fig = plot_mosaic(image, overlay_mask=args.template_mask, title="SPM template registration")
    fig.savefig(snap, dpi=300)
Example #3
0
        qc[key] = float(value)
    if isinstance(value, numpy.core.memmap):
        if value.dtype == numpy.single or value.dtype == numpy.double:
            qc[key] = float(value)
        elif value.dtype == numpy.int:
            qc[key] = int(value)
        else:
            raise ValueError("Unexpected value type '{0}:{1}'".format(
                key, value))
with open(scores_json, "w") as open_file:
    json.dump(qc, open_file, indent=4)

# Control FOV
mean_snap = os.path.join(subjectdir, "mean_epi.pdf")
figures.append(mean_snap)
fig = plot_mosaic(args.meanepi, title="Mean EPI")
fig.savefig(mean_snap, dpi=300)
fov_coverage, fov_score = control_fov(args.maskrealign, threshold=0, verbose=0)

if args.slmask:
    # measure signal loss in brain region (e.g. lower anterior quadrant)
    sl_value = signal_loss(args.wrappedmean,
                           args.meanwrappedmask,
                           args.slmask,
                           verbose=0)
else:
    sl_value = None

# Control wrapping on template
if args.wrappedmean:
    mean_snap_norm = os.path.join(subjectdir, "mean_normalized_epi_masked.pdf")