Beispiel #1
0
 def _run_interface(self, runtime):
     out = extractnetstats(self.inputs.ID, self.inputs.network,
                           self.inputs.thr, self.inputs.conn_model,
                           self.inputs.est_path, self.inputs.roi,
                           self.inputs.prune, self.inputs.node_size,
                           self.inputs.norm, self.inputs.binary)
     setattr(self, '_outpath', out)
     return runtime
def test_extractnetstats(binary, prune, norm):
    """
    Test extractnetstats functionality
    """
    base_dir = str(Path(__file__).parent / "examples")
    ID = '002'
    network = 'Default'
    thr = 0.95
    conn_model = 'cov'
    est_path = f"{base_dir}/miscellaneous/sub-0021001_rsn-Default_nodetype-parc_model-sps_template-MNI152_T1_thrtype-DENS_thr-0.19.npy"
    prune = 1
    norm = 1
    binary = False
    roi = None

    start_time = time.time()
    out_path = netstats.extractnetstats(ID, network, thr, conn_model, est_path,
                                        roi, prune, norm, binary)
    print("%s%s%s" % (
        'thresh_and_fit (Functional, proportional thresholding) --> finished: ',
        str(np.round(time.time() - start_time, 1)), 's'))
    assert out_path is not None

    # Cover exceptions. This can definiely be improved. It increases coverage, but not as throughly
    # as I hoped.
    from tempfile import NamedTemporaryFile
    f_temp = NamedTemporaryFile(mode='w+', suffix='.npy')

    nan_array = np.empty((5, 5))
    nan_array[:] = np.nan

    np.save(f_temp.name, nan_array)
    est_path = f_temp.name

    try:
        out_path = netstats.extractnetstats(ID, network, thr, conn_model,
                                            est_path, roi, prune, norm, binary)
    except PermissionError:
        pass
Beispiel #3
0
def test_extractnetstats():
    base_dir = str(Path(__file__).parent/"examples")
    ID = '002'
    network = 'Default'
    thr = 0.95
    conn_model = 'cov'
    est_path = base_dir + '/002/fmri/002_Default_est_cov_0.95prop_TESTmm_3nb_2fwhm_0.1Hz.npy'
    prune = 1
    node_size = 'parc'
    norm = 1
    binary = False
    roi = None

    start_time = time.time()
    out_path = netstats.extractnetstats(ID, network, thr, conn_model, est_path, roi, prune, node_size, norm, binary)
    print("%s%s%s" % ('thresh_and_fit (Functional, proportional thresholding) --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))
    assert out_path is not None
Beispiel #4
0
def test_extractnetstats(binary, prune, norm):
    """
    Test extractnetstats functionality
    """
    base_dir = str(Path(__file__).parent / "examples")
    ID = '002'
    network = 'Default'
    thr = 0.95
    conn_model = 'cov'
    est_path = base_dir + '/002/fmri/DesikanKlein2012/graphs/0021001_Default_est_sps_0.19densparc_mm.npy'
    prune = 1
    norm = 1
    binary = False
    roi = None

    start_time = time.time()
    out_path = netstats.extractnetstats(ID, network, thr, conn_model, est_path,
                                        roi, prune, norm, binary)
    print("%s%s%s" % (
        'thresh_and_fit (Functional, proportional thresholding) --> finished: ',
        str(np.round(time.time() - start_time, 1)), 's'))
    assert out_path is not None