Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Changes model module -> metrics module #325

Merged
merged 3 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@ API
.. _calibration_ref:


:mod:`tedana.model`: Computing TE-dependence metrics
:mod:`tedana.metrics`: Computing TE-dependence metrics
----------------------------------------------------

.. automodule:: tedana.model
.. automodule:: tedana.metrics
:no-members:
:no-inherited-members:

.. autosummary:: tedana.model
.. autosummary:: tedana.metrics
:toctree: generated/
:template: function.rst

tedana.model.dependence_metrics
tedana.model.kundu_metrics
tedana.metrics.dependence_metrics
tedana.metrics.kundu_metrics

:template: module.rst

tedana.model.fit
tedana.metrics.fit

.. currentmodule:: tedana

Expand Down
4 changes: 2 additions & 2 deletions tedana/decomposition/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from scipy import stats
from sklearn.decomposition import PCA

from tedana import model, utils, io
from tedana import metrics, utils, io
from tedana.decomposition._utils import eimask
from tedana.stats import computefeats2
from tedana.selection import kundu_tedpca
Expand Down Expand Up @@ -201,7 +201,7 @@ def tedpca(data_cat, data_oc, combmode, mask, t2s, t2sG,

# Normalize each component's time series
vTmixN = stats.zscore(comp_ts, axis=0)
comptable, _, _, _ = model.dependence_metrics(
comptable, _, _, _ = metrics.dependence_metrics(
data_cat, data_oc, comp_ts, eimum, t2s, tes, ref_img,
reindex=False, mmixN=vTmixN, algorithm=None,
label='mepca_', out_dir=out_dir, verbose=verbose)
Expand Down
2 changes: 1 addition & 1 deletion tedana/model/__init__.py → tedana/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 et:

from .fit import (
from .kundu_fit import (
dependence_metrics, kundu_metrics, get_coeffs, computefeats2
)

Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions tedana/tests/test_model_fit_dependence_metrics.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
Tests for tedana.model.fit
Tests for tedana.metrics.fit
"""

import numpy as np
import pytest

from tedana.model import fit
from tedana.metrics import kundu_fit


def test_break_dependence_metrics():
Expand All @@ -27,7 +27,7 @@ def test_break_dependence_metrics():
# Shape of catd is wrong
catd = np.empty((n_samples+1, n_echos, n_vols))
with pytest.raises(ValueError) as e_info:
fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
kundu_fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
t2s=t2s, tes=tes, ref_img=ref_img,
reindex=False, mmixN=None, algorithm='kundu_v3')
assert str(e_info.value) == ('First dimensions (number of samples) of '
Expand All @@ -40,7 +40,7 @@ def test_break_dependence_metrics():
catd = np.empty((n_samples, n_echos, n_vols))
t2s = np.empty((n_samples+1, n_vols))
with pytest.raises(ValueError) as e_info:
fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
kundu_fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
t2s=t2s, tes=tes, ref_img=ref_img,
reindex=False, mmixN=None, algorithm='kundu_v3')
assert str(e_info.value) == ('First dimensions (number of samples) of '
Expand All @@ -53,7 +53,7 @@ def test_break_dependence_metrics():
t2s = np.empty((n_samples, n_vols))
tsoc = np.empty((n_samples+1, n_vols))
with pytest.raises(ValueError) as e_info:
fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
kundu_fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
t2s=t2s, tes=tes, ref_img=ref_img,
reindex=False, mmixN=None, algorithm='kundu_v3')
assert str(e_info.value) == ('First dimensions (number of samples) of '
Expand All @@ -66,7 +66,7 @@ def test_break_dependence_metrics():
catd = np.empty((n_samples, n_echos+1, n_vols))
tsoc = np.empty((n_samples, n_vols))
with pytest.raises(ValueError) as e_info:
fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
kundu_fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
t2s=t2s, tes=tes, ref_img=ref_img,
reindex=False, mmixN=None, algorithm='kundu_v3')
assert str(e_info.value) == ('Second dimension of catd ({0}) does not '
Expand All @@ -77,7 +77,7 @@ def test_break_dependence_metrics():
# Shape of catd is wrong
catd = np.empty((n_samples, n_echos, n_vols+1))
with pytest.raises(ValueError) as e_info:
fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
kundu_fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
t2s=t2s, tes=tes, ref_img=ref_img,
reindex=False, mmixN=None, algorithm='kundu_v3')
assert str(e_info.value) == ('Number of volumes in catd '
Expand All @@ -90,7 +90,7 @@ def test_break_dependence_metrics():
catd = np.empty((n_samples, n_echos, n_vols))
t2s = np.empty((n_samples, n_vols+1))
with pytest.raises(ValueError) as e_info:
fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
kundu_fit.dependence_metrics(catd=catd, tsoc=tsoc, mmix=mmix, mask=mask,
t2s=t2s, tes=tes, ref_img=ref_img,
reindex=False, mmixN=None, algorithm='kundu_v3')
assert str(e_info.value) == ('Number of volumes in catd ({0}) '
Expand Down
4 changes: 2 additions & 2 deletions tedana/tests/test_model_kundu_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pandas as pd

from tedana.model import fit
from tedana.metrics import kundu_fit


def test_smoke_kundu_metrics():
Expand Down Expand Up @@ -34,5 +34,5 @@ def test_smoke_kundu_metrics():
metric_maps['Br_R2_clmaps'] = np.random.randint(low=0, high=2,
size=(n_voxels, n_comps))

comptable = fit.kundu_metrics(comptable, metric_maps)
comptable = kundu_fit.kundu_metrics(comptable, metric_maps)
assert comptable is not None
4 changes: 2 additions & 2 deletions tedana/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
matplotlib.use('AGG')
import matplotlib.pyplot as plt

from tedana import model
from tedana import metrics
from tedana.utils import get_spectrum

LGR = logging.getLogger(__name__)
Expand Down Expand Up @@ -77,7 +77,7 @@ def write_comp_figs(ts, mask, comptable, mmix, ref_img, out_dir,
LGR.warning('Provided colormap is not recognized, proceeding with default')
png_cmap = 'coolwarm'
# regenerate the beta images
ts_B = model.get_coeffs(ts, mmix, mask)
ts_B = metrics.get_coeffs(ts, mmix, mask)
ts_B = ts_B.reshape(ref_img.shape[:3] + ts_B.shape[1:])
# trim edges from ts_B array
ts_B = trim_edge_zeros(ts_B)
Expand Down
10 changes: 5 additions & 5 deletions tedana/workflows/tedana.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from scipy import stats
from nilearn.masking import compute_epi_mask

from tedana import (decay, combine, decomposition, io, model, selection, utils,
from tedana import (decay, combine, decomposition, io, metrics, selection, utils,
viz)
import tedana.gscontrol as gsc
from tedana.workflows.parser_utils import is_valid_file
Expand Down Expand Up @@ -403,23 +403,23 @@ def tedana_workflow(data, tes, mask=None, mixm=None, ctab=None, manacc=None,
# Estimate betas and compute selection metrics for mixing matrix
# generated from dimensionally reduced data using full data (i.e., data
# with thermal noise)
comptable, metric_maps, betas, mmix = model.dependence_metrics(
comptable, metric_maps, betas, mmix = metrics.dependence_metrics(
catd, data_oc, mmix_orig, mask, t2s, tes,
ref_img, reindex=True, label='meica_', out_dir=out_dir,
algorithm='kundu_v2', verbose=verbose)
np.savetxt(op.join(out_dir, 'meica_mix.1D'), mmix)

comptable = model.kundu_metrics(comptable, metric_maps)
comptable = metrics.kundu_metrics(comptable, metric_maps)
comptable = selection.kundu_selection_v2(comptable, n_echos, n_vols)
else:
LGR.info('Using supplied mixing matrix from ICA')
mmix_orig = np.loadtxt(op.join(out_dir, 'meica_mix.1D'))
comptable, metric_maps, betas, mmix = model.dependence_metrics(
comptable, metric_maps, betas, mmix = metrics.dependence_metrics(
catd, data_oc, mmix_orig, mask, t2s, tes,
ref_img, label='meica_', out_dir=out_dir,
algorithm='kundu_v2', verbose=verbose)
if ctab is None:
comptable = model.kundu_metrics(comptable, metric_maps)
comptable = metrics.kundu_metrics(comptable, metric_maps)
comptable = selection.kundu_selection_v2(comptable, n_echos, n_vols)
else:
comptable = pd.read_csv(ctab, sep='\t', index_col='component')
Expand Down