Skip to content

Commit fc67e1a

Browse files
committed
FIX: Use len(segments) to avoid nsegments becoming wrong
1 parent 85dc9f7 commit fc67e1a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

niworkflows/viz/plots.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ def plot_carpet(
196196
"whole brain (voxels)": list(range(data.shape[0]))
197197
}
198198

199-
nsegments = len(segments)
200-
if nsegments == 1:
199+
if len(segments) == 1:
201200
legend = False
202201

203202
if cmap is None:
@@ -256,7 +255,7 @@ def plot_carpet(
256255

257256
# Define nested GridSpec
258257
gs = mgs.GridSpecFromSubplotSpec(
259-
nsegments,
258+
len(segments),
260259
1,
261260
subplot_spec=subplot,
262261
hspace=0.05,
@@ -294,7 +293,7 @@ def plot_carpet(
294293
ax.set_yticks([])
295294
ax.grid(False)
296295

297-
if i == (nsegments - 1):
296+
if i == (len(segments) - 1):
298297
xlabel = "time-points (index)"
299298
xticklabels = (xticks * n_trs / data.shape[-1]).astype("uint32") + drop_trs
300299
if tr is not None:
@@ -318,7 +317,7 @@ def plot_carpet(
318317
if title and i == 0:
319318
ax.set_title(title)
320319

321-
if nsegments == 1:
320+
if len(segments) == 1:
322321
ax.set_ylabel(label)
323322

324323
if legend:

0 commit comments

Comments
 (0)