@@ -241,6 +241,46 @@ def to_nifti(self, filename: Path | str, insert_b0: bool = False) -> None:
241
241
np .savetxt (bvecs_file , self .gradients [:3 , ...].T , fmt = "%.6f" )
242
242
np .savetxt (bvals_file , self .gradients [:3 , ...], fmt = "%.6f" )
243
243
244
+ @property
245
+ def shells (
246
+ self ,
247
+ num_bins : int = DEFAULT_NUM_BINS ,
248
+ multishell_nonempty_bin_count_thr : int = DEFAULT_MULTISHELL_BIN_COUNT_THR ,
249
+ bval_cap : int = DEFAULT_HIGHB_THRESHOLD ,
250
+ ):
251
+ """Get the shell data according to the b-value groups.
252
+
253
+ Bin the shell data according to the b-value groups found by `~find_shelling_scheme`.
254
+
255
+ Parameters
256
+ ----------
257
+ num_bins : :obj:`int`, optional
258
+ Number of bins.
259
+ multishell_nonempty_bin_count_thr : :obj:`int`, optional
260
+ Bin count to consider a multi-shell scheme.
261
+ bval_cap : :obj:`int`, optional
262
+ Maximum b-value to be considered in a multi-shell scheme.
263
+
264
+ Returns
265
+ -------
266
+ :obj:`list`
267
+ Tuples of binned b-values and corresponding shell data.
268
+ """
269
+
270
+ _ , bval_groups , bval_estimated = find_shelling_scheme (
271
+ self .gradients [- 1 , ...],
272
+ num_bins = num_bins ,
273
+ multishell_nonempty_bin_count_thr = multishell_nonempty_bin_count_thr ,
274
+ bval_cap = bval_cap ,
275
+ )
276
+ indices = [
277
+ np .hstack (np .where (np .isin (self .gradients [- 1 , ...], bvals ))) for bvals in bval_groups
278
+ ]
279
+ return [
280
+ (bval_estimated [idx ], self .dataobj [indices , ...])
281
+ for idx , indices in enumerate (indices )
282
+ ]
283
+
244
284
245
285
def load (
246
286
filename : Path | str ,
0 commit comments