Skip to content

Commit 859b80b

Browse files
committed
Add option to cluster from negative values
1 parent 2c1daa3 commit 859b80b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

defineROICluster.py

+12
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
default is a lower bound of 1.64 (z-score giving one-tailed p < 0.05),
4545
and the upper bound is disabled.
4646
47+
--negative
48+
If specified, sign-flip the input volume so that the clustering is based
49+
on the negative tail of the values (note that thresholds and bounds should
50+
still be given in positive units).
51+
4752
Example usage
4853
-------------
4954
Define 100 voxel cluster from zstat around seed at [10,20,30]
@@ -159,6 +164,8 @@ class CustomFormatter(argparse.RawTextHelpFormatter,
159164
help='Lower-bound threshold; set to inf or nan to disable')
160165
parser.add_argument('--upper-bound', type=float, default='nan',
161166
help='Upper-bound threshold; set to inf or nan to disable')
167+
parser.add_argument('--negative', action='store_true',
168+
help='Define cluster from negative values')
162169

163170
# If no arguments given, print help and exit
164171
if not len(sys.argv) > 1:
@@ -175,6 +182,7 @@ class CustomFormatter(argparse.RawTextHelpFormatter,
175182
start_thresholds = args.start_thr
176183
lower_bound = args.lower_bound
177184
upper_bound = args.upper_bound
185+
negative = args.negative
178186

179187
# Append outfile extension if none given
180188
if '.' not in outfile:
@@ -200,6 +208,10 @@ class CustomFormatter(argparse.RawTextHelpFormatter,
200208
maskvol = nib.load(initial_mask).get_fdata().astype(bool)
201209
vol *= maskvol
202210

211+
# Sign-flip?
212+
if negative:
213+
vol *= -1
214+
203215
# Check lower bound appropriate for seed
204216
if (lower_bound is not None) and (vol[tuple(seed_coord)] < lower_bound):
205217
raise ValueError('Lower bound cannot exceed value at seed voxel')

0 commit comments

Comments
 (0)