-
Notifications
You must be signed in to change notification settings - Fork 92
/
tedica.py
76 lines (61 loc) · 2.73 KB
/
tedica.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Functions to identify TE-dependent and TE-independent components.
"""
import logging
from tedana.metrics import collect
from tedana.selection.component_selector import ComponentSelector
LGR = logging.getLogger("GENERAL")
RepLGR = logging.getLogger("REPORT")
def automatic_selection(component_table, n_echos, n_vols, tree="kundu", verbose=False):
"""Classify components based on component table and decision tree type.
Parameters
----------
component_table : :obj:`pd.DataFrame`
The component table to classify
n_echos : :obj:`int`
The number of echoes in this dataset
tree : :obj:`str`
The type of tree to use for the ComponentSelector object. Default="kundu"
verbose : :obj:`bool`
More verbose logging output if True. Default=False
Returns
-------
selector : :obj:`tedana.selection.component_selector.ComponentSelector`
Contains component classifications in a component_table and provenance
and metadata from the component selection process
Notes
-----
If tree=kundu, the selection algorithm used in this function was originated in ME-ICA
by Prantik Kundu, and his original implementation is available at:
https://github.com/ME-ICA/me-ica/blob/\
b2781dd087ab9de99a2ec3925f04f02ce84f0adc/meica.libs/select_model.py
The appropriate citation is :footcite:t:`kundu2013integrated`.
This component selection process uses multiple, previously calculated
metrics that include kappa, rho, variance explained, noise and spatial
frequency metrics, and measures of spatial overlap across metrics.
Prantik began to update these selection criteria to use SVMs to distinguish
components, a hypercommented version of this attempt is available at:
https://gist.github.com/emdupre/ca92d52d345d08ee85e104093b81482e
If tree=="minimal", a selection algorithm based on the "kundu" tree will be used.
The differences between the "minimal" and "kundu" trees are described in the `FAQ`_.
References
----------
.. footbibliography::
.. _FAQ: faq.html
"""
LGR.info("Performing ICA component selection with Kundu decision tree v2.5")
RepLGR.info(
"Next, component selection was performed to identify "
"BOLD (TE-dependent), non-BOLD (TE-independent), and "
"uncertain (low-variance) components using the Kundu "
"decision tree (v2.5) \\citep{kundu2013integrated}."
)
component_table["classification_tags"] = ""
xcomp = {
"n_echos": n_echos,
"n_vols": n_vols,
}
selector = ComponentSelector(tree, component_table, cross_component_metrics=xcomp)
selector.select()
selector.metadata = collect.get_metadata(selector.component_table)
return selector