|
1 | 1 | import argparse |
2 | 2 | import sys |
3 | 3 |
|
| 4 | +import numpy as np |
4 | 5 | import pandas as pd |
5 | 6 |
|
6 | 7 | from tedana_regressors import __version__ |
@@ -40,32 +41,38 @@ def _get_parser(): |
40 | 41 | def tedana_regressors(ctab, mix, prefix): |
41 | 42 |
|
42 | 43 | # Load component table and mixing matrix into pandas dataframes |
| 44 | + np.print("Loading component table and mixing matrix...") |
43 | 45 | ctab_df = pd.read_csv(ctab, sep="\t", index_col=0) |
44 | 46 | mix_df = pd.read_csv(mix, sep="\t", index_col=None) |
45 | 47 |
|
46 | 48 | # Extract the indices of the components that have "accepted" in the "classification" column of |
47 | 49 | # ctab_df |
| 50 | + print("Extracting and saving accepted components...") |
48 | 51 | accepted_components = ctab_df.loc[ctab_df["classification"] == "accepted"].index |
49 | 52 |
|
50 | 53 | # Create matrix with the columns of the mixing matrix corresponding to keys in |
51 | 54 | # accepted_components and save it |
52 | | - df_to_matrix(mix_df, accepted_components).to_csv(prefix + "_accepted.1D", sep=" ", index=False) |
| 55 | + np.savetxt(prefix + "_accepted.1D", df_to_matrix(mix_df, accepted_components), delimiter=" ") |
53 | 56 |
|
54 | 57 | # Extract the indices of the components that have "rejected" in the "classification" column of |
55 | 58 | # ctab_df |
| 59 | + print("Extracting and saving rejected components...") |
56 | 60 | rejected_components = ctab_df.loc[ctab_df["classification"] == "rejected"].index |
57 | | - |
| 61 | + |
58 | 62 | # Create matrix with the columns of the mixing matrix corresponding to keys in |
59 | 63 | # rejected_components and save it |
60 | | - df_to_matrix(mix_df, rejected_components).to_csv(prefix + "_rejected.1D", sep=" ", index=False) |
| 64 | + np.savetxt(prefix + "_rejected.1D", df_to_matrix(mix_df, rejected_components), delimiter=" ") |
61 | 65 |
|
62 | 66 | # Extract the indices of the components that have "ignored" in the "classification" column of |
63 | 67 | # ctab_df |
| 68 | + print("Extracting and saving ignored components...") |
64 | 69 | ignored_components = ctab_df.loc[ctab_df["classification"] == "ignored"].index |
65 | 70 |
|
66 | 71 | # Create matrix with the columns of the mixing matrix corresponding to keys in |
67 | 72 | # ignored_components and save it |
68 | | - df_to_matrix(mix_df, ignored_components).to_csv(prefix + "_ignored.1D", sep=" ", index=False) |
| 73 | + np.savetxt(prefix + "_ignored.1D", df_to_matrix(mix_df, ignored_components), delimiter=" ") |
| 74 | + |
| 75 | + print("Done.") |
69 | 76 |
|
70 | 77 |
|
71 | 78 | def _main(argv=None): |
|
0 commit comments