Skip to content

Commit 8541610

Browse files
committed
Merge pull request #285 from rdvincent/master
Add a range check to avoid weird wrapping effect with negative slice_num
2 parents 2bf7cd4 + 600d639 commit 8541610

File tree

1 file changed

+10
-8
lines changed
  • src/brainbrowser/volume-viewer/volume-loaders

1 file changed

+10
-8
lines changed

src/brainbrowser/volume-viewer/volume-loaders/minc.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,19 @@
141141
var i = 0;
142142

143143
z = z_positive ? slice_num : axis_space.space_length - slice_num - 1;
144-
tz_offset = time_offset + z * axis_space_offset;
144+
if (z >= 0 && z < axis_space.space_length) {
145+
tz_offset = time_offset + z * axis_space_offset;
145146

146-
for (row = height - 1; row >= 0; row--) {
147-
y = y_positive ? row : height - row - 1;
148-
tzy_offset = tz_offset + y * height_space_offset;
147+
for (row = height - 1; row >= 0; row--) {
148+
y = y_positive ? row : height - row - 1;
149+
tzy_offset = tz_offset + y * height_space_offset;
149150

150-
for (col = 0; col < width; col++) {
151-
x = x_positive ? col : width - col - 1;
152-
tzyx_offset = tzy_offset + x * width_space_offset;
151+
for (col = 0; col < width; col++) {
152+
x = x_positive ? col : width - col - 1;
153+
tzyx_offset = tzy_offset + x * width_space_offset;
153154

154-
slice_data[i++] = volume.data[tzyx_offset];
155+
slice_data[i++] = volume.data[tzyx_offset];
156+
}
155157
}
156158
}
157159

0 commit comments

Comments
 (0)