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