def test_qap_functional_spatial(): import os import pkg_resources as p from qap.qap_workflows_utils import qap_functional_spatial mean_func = p.resource_filename("qap", os.path.join(test_sub_dir, \ "rest_1", \ "mean_functional", \ "rest_calc_tshift_resample_volreg_" \ "tstat.nii.gz")) func_mask = p.resource_filename("qap", os.path.join(test_sub_dir, \ "rest_1", \ "functional_brain_mask", \ "rest_calc_tshift_resample_volreg_" \ "mask.nii.gz")) subject = "1019436" session = "session_1" scan = "rest_1" direction = "y" qc = qap_functional_spatial(mean_func, func_mask, direction, subject, \ session, scan) assert (len(qc.keys()) == 17) and (None not in qc.values())
subjectdir = os.path.join(args.outdir, args.subjectid) if not os.path.isdir(subjectdir): os.mkdir(subjectdir) if args.erase: shutil.rmtree(subjectdir) os.mkdir(subjectdir) """ QAP spatial """ # out_vox: output the FWHM as # of voxels (otherwise as mm) # direction: used to compute signal present outside the brain due to # acquisition in the phase encoding direction # > compute functional spatial scores from QAP library qc = qap_functional_spatial(args.meanrealign, args.maskrealign, args.direction, args.subjectid, "mysession", "myscan", site_name="mysite", out_vox=True) # > save scores as a Json file scores_json = os.path.join(subjectdir, "qap_functional_spatial.json") qc.pop("session") qc.pop("scan") qc.pop("site") for key, value in qc.items(): if isinstance(value, numpy.double) or isinstance(value, numpy.single): 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)
time_axis=-1, slice_axis=-2, mvt_thr=50, rot_thr=50, volumes_to_ignore=args.crop) """ QAP spatial """ # out_vox: output the FWHM as # of voxels (otherwise as mm) # direction: used to compute signal present outside the brain due to # acquisition in the phase encoding direction # > compute functional spatial scores from QAP library qc = qap_functional_spatial(args.meanrealign, args.maskrealign, args.direction, args.subjectid, "mysession", "myscan", site_name="mysite", out_vox=True) # > save scores as a Json file scores_json = os.path.join(subjectdir, "qap_functional_spatial.json") qc.pop("session") qc.pop("scan") qc.pop("site") for key, value in qc.items(): if isinstance(value, numpy.double) or isinstance(value, numpy.single): qc[key] = float(value) if isinstance(value, numpy.core.memmap): if value.dtype == numpy.single or value.dtype == numpy.double: qc[key] = float(value)