Pixel subtraction with hyperstacks in FIJI works unexpectedly

I would like to subtract a constant value from all pixels in a selected channel within a hyperstack. However, running the subtraction operation (Process > Math > Subtract…) indiscriminately modifies all channels in the hyperstack irregardless of the currently selected channel.

For example, in macro 1 below, why does pixel subtraction operate on ALL channels even though channel 1 is explicitly selected? For comparison, other commands passed in the same way only operate on the selected channel, as in macro 2.

(EDIT: I later realized that passing the “slice” keyword to the run(“Subtract…”) command achieves what I wanted.

However, this wasn’t obvious at first since the macro recorder OMITTED this keyword when I had selected a specific channel using the channel slider. In contrast, after I had selected a specific channel using the Channels Tool, then the “slice” keyword was included by the recorder.

Is there a reason for this behavior? Can it be fixed so that selecting a channel using the channel slider would behave identically to selecting a channel with the Chanels Tool?)

// modifies all channels
macro "1" {
run("Fluorescent Cells (400K)");
Stack.setChannel(1);
run("Subtract...", "value=1000");
}

// modifies only the selected channel
macro "2" {
run("Fluorescent Cells (400K)");
Stack.setChannel(1);
run("Enhance Contrast...", "saturated=5");
}
1 Like

Switch to “Color” display mode using the Image>Color>Channels tool and the Process>Math>Subtract command, and the command recorder, will work as expected with multi-channel images. The Subtract command assumes you want to process all the channels if the image is displayed in “Composite” mode.

OK thank you! I will make sure to use the Channels Tool with hypertacks from now on to retrieve the accurate commands.