Skip to content

Commit 3ba85f4

Browse files
authored
Merge pull request #18 from nel-lab/default-ixs-components
fixes #14
2 parents fe19bac + 88e381e commit 3ba85f4

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

mesmerize_core/algorithms/cnmf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def main(batch_path, uuid, data_path: str = None):
6161
proj_paths = dict()
6262
for proj_type in ['mean', 'std', 'max']:
6363
p_img = getattr(np, f'nan{proj_type}')(images, axis=0)
64-
proj_paths[proj_type] = Path(input_movie_path).parent.joinpath(f'{uuid}_{proj_type}.npy')
64+
proj_paths[proj_type] = Path(input_movie_path).parent.joinpath(f'{uuid}_{proj_type}_projection.npy')
6565
np.save(str(proj_paths[proj_type]), p_img)
6666

6767
# in fname new load in memmap order C

mesmerize_core/algorithms/cnmfe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def main(batch_path, uuid, data_path: str = None):
5252
proj_paths = dict()
5353
for proj_type in ['mean', 'std', 'max']:
5454
p_img = getattr(np, f'nan{proj_type}')(images, axis=0)
55-
proj_paths[proj_type] = Path(input_movie_path).parent.joinpath(f'{uuid}_{proj_type}.npy')
55+
proj_paths[proj_type] = Path(input_movie_path).parent.joinpath(f'{uuid}_{proj_type}_projection.npy')
5656
np.save(str(proj_paths[proj_type]), p_img)
5757

5858
downsample_ratio = params['downsample_ratio']

mesmerize_core/algorithms/mcorr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def main(batch_path, uuid, data_path: str = None):
7171
proj_paths = dict()
7272
for proj_type in ['mean', 'std', 'max']:
7373
p_img = getattr(np, f'nan{proj_type}')(images, axis=0)
74-
proj_paths[proj_type] = Path(input_movie_path).parent.joinpath(f'{uuid}_{proj_type}.npy')
74+
proj_paths[proj_type] = Path(input_movie_path).parent.joinpath(f'{uuid}_{proj_type}_projection.npy')
7575
np.save(str(proj_paths[proj_type]), p_img)
7676

7777
print("Computing correlation image")

mesmerize_core/caiman_extensions/cnmf.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ def get_output(self) -> CNMF:
8181

8282
# TODO: Make the ``ixs`` parameter for spatial stuff optional
8383
@validate('cnmf')
84-
def get_spatial_masks(self, ixs_components: np.ndarray, threshold: float = 0.01) -> np.ndarray:
84+
def get_spatial_masks(
85+
self,
86+
ixs_components: Optional[np.ndarray] = None,
87+
threshold: float = 0.01
88+
) -> np.ndarray:
8589
"""
8690
Get binary masks of the spatial components at the given `ixs`
8791
@@ -90,7 +94,8 @@ def get_spatial_masks(self, ixs_components: np.ndarray, threshold: float = 0.01)
9094
Parameters
9195
----------
9296
ixs_components: np.ndarray
93-
numpy array containing integer indices for which you want spatial masks
97+
numpy array containing integer indices for which you want spatial masks.
98+
if `None` uses cnmf.estimates.idx_components
9499
95100
threshold: float
96101
threshold
@@ -107,6 +112,9 @@ def get_spatial_masks(self, ixs_components: np.ndarray, threshold: float = 0.01)
107112
if dims is None:
108113
dims = cnmf_obj.estimates.dims
109114

115+
if ixs_components is None:
116+
ixs_components = cnmf_obj.estimates.idx_components
117+
110118
masks = np.zeros(shape=(dims[0], dims[1], len(ixs_components)), dtype=bool)
111119

112120
for n, ix in enumerate(ixs_components):
@@ -152,7 +160,7 @@ def get_spatial_contours(
152160
----------
153161
ixs_components: np.ndarray
154162
indices for which to return spatial contours.
155-
if `None` just returns according to cnmf.estimates.idx_components
163+
if `None` uses cnmf.estimates.idx_components
156164
157165
Returns
158166
-------
@@ -175,14 +183,19 @@ def get_spatial_contours(
175183
return coordinates, coms
176184

177185
@validate('cnmf')
178-
def get_temporal_components(self, ixs_components: np.ndarray = None, add_background: bool = False) -> np.ndarray:
186+
def get_temporal_components(
187+
self,
188+
ixs_components: Optional[np.ndarray] = None,
189+
add_background: bool = False
190+
) -> np.ndarray:
179191
"""
180192
Get the temporal components for this CNMF item
181193
182194
Parameters
183195
----------
184196
ixs_components: np.ndarray
185-
indices for which to return temporal components, ``cnmf.estimates.C``
197+
indices for which to return temporal components, ``cnmf.estimates.C``.
198+
if `None` uses cnmf.estimates.idx_components
186199
187200
add_background: bool
188201
if ``True``, add the temporal background, basically ``cnmf.estimates.C + cnmf.estimates.f``
@@ -194,7 +207,7 @@ def get_temporal_components(self, ixs_components: np.ndarray = None, add_backgro
194207
cnmf_obj = self.get_output()
195208

196209
if ixs_components is None:
197-
ixs_components = np.arange(0, cnmf_obj.estimates.C.shape[0])
210+
ixs_components = cnmf_obj.estimates.idx_components
198211

199212
C = cnmf_obj.estimates.C[ixs_components]
200213
f = cnmf_obj.estimates.f

0 commit comments

Comments
 (0)