|
8 | 8 | absolute_import) |
9 | 9 | from builtins import range |
10 | 10 |
|
| 11 | +# Py2 compat: http://python-future.org/compatible_idioms.html#collections-counter-and-ordereddict |
| 12 | +from future import standard_library |
| 13 | +standard_library.install_aliases() |
| 14 | +from collections import OrderedDict |
| 15 | + |
11 | 16 | import os |
12 | 17 | import os.path as op |
13 | 18 |
|
@@ -1230,7 +1235,7 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5, |
1230 | 1235 | Numpy array containing the requested set of noise components |
1231 | 1236 | basis: numpy array |
1232 | 1237 | Numpy array containing the (non-constant) filter regressors |
1233 | | - metadata: dict(numpy array) |
| 1238 | + metadata: OrderedDict{str: numpy array} |
1234 | 1239 | Dictionary of eigenvalues, fractional explained variances, and |
1235 | 1240 | cumulative explained variances. |
1236 | 1241 | """ |
@@ -1296,13 +1301,12 @@ def compute_noise_components(imgseries, mask_images, components_criterion=0.5, |
1296 | 1301 | num_components = int(components_criterion) |
1297 | 1302 | if components is None: |
1298 | 1303 | components = u[:, :num_components] |
1299 | | - metadata = { |
1300 | | - 'mask': np.array([i] * num_components), |
1301 | | - 'singular_value': s[:num_components], |
1302 | | - 'variance_explained': variance_explained[:num_components], |
1303 | | - 'cumulative_variance_explained': |
1304 | | - cumulative_variance_explained[:num_components] |
1305 | | - } |
| 1304 | + metadata = OrderedDict() |
| 1305 | + metadata['mask'] = np.array([i] * num_components) |
| 1306 | + metadata['singular_value'] = s[:num_components] |
| 1307 | + metadata['variance_explained'] = variance_explained[:num_components] |
| 1308 | + metadata['cumulative_variance_explained'] = ( |
| 1309 | + cumulative_variance_explained[:num_components]) |
1306 | 1310 | else: |
1307 | 1311 | components = np.hstack((components, u[:, :num_components])) |
1308 | 1312 | metadata['mask'] = np.hstack((metadata['mask'], |
|
0 commit comments