Swap slices and swap volumes

From MIPAV
Jump to: navigation, search

Background

Both Swap Slices and Swap Volumes allow the user to select slices and volumes of interest and to 1) insert selected slices\volumes into different locations in the image, 2) delete all selected slices\volumes at once, 3) move selected slices\volumes, and 4) append selected slices\volumes to the end of the image.

Why swap slices and volumes?

In DTI scanning B0 volume (the volume made without a b pulse) is used for creating a whole-brain mask, which is used to determine which voxels to include into analysis. For most of MRI scanners B0 is either the fist or the last recorded volume, but some scanners put B0 is some other places (e.g. in the middle of the image). The easiest way to move B0 volume to the beginning or to the end of the image is by using the Swap Volumes tool.

The Swap Slices tool is helpful when the user needs to remove\replace a bunch of slices from the beginning or from the end of image (or both). For example in brain MRI, researches are often interested in the middle slices. The same applies to microscopy where first and last slices are usually out of focus.

Image types

Both Swap Slices and Swap Volumes could be applied to images of all image types and modalities supported by MIPAV. The result image is saved in the same format\type as the original image. Swap Volumes could be run only for 4D images, while Swap Slices could be run for both 3D and 4D images.

Swap Slices

Utilities > 3D Tools > Swap Slices

The Swap Slices tool is available via Utilities > 3D Slice Tools > Swap Slices. The tool could be run for both 3D and 4D images. In case of a 4D image it interchanges (swaps) slices around all volumes in the image.

Running Swap Slices for 3D images

To run the Swap Slices tool, open an image of interest and call the tool via the Utilities > 3D Slice Tools > Swap Slices menu. The Swap Slices dialog box appears.

Swap Slices dialog box

Upper menu:

For Load and Save options, refer to Load and save profile.

Help - calls the help for this dialog box.

In the dialog box one can see 2 columns:

  • The right column is called Slice and it contains slice numbers;
  • The left column is called Index and it contains position numbers.

Slice number is the number of the slice as it encoded in the image header.

Position number is the position of the slice in the image. It shows where exactly in the image the slice is located. For the image that did not undergone any slice swapping the position number and the slice number are the same. E.g. slice #0 - position #0, slice #1 - position #1, slice #2 - position #2, ... slice #N - position #N.

Destination - by default the modified image will appear in the new image frame.

Swap - press Swap to move\copy\delete selected volumes and to save a modified image. The new image appears in a new image frame. You can also press S on your keyboard to run the command.

Reset - restores the values in a dialog box to the initial values. You can also press S on your keyboard to run the command.

Undo - undoes the most recent action (only). You can also press U on your keyboard to run the command.

Redo - re-does the action that was undone by Undo. You can also press d on your keyboard to run the command.

Append - adds a bunch of copied slices\volumes to the end of the image. You can also press A on your keyboard to run the command.

Copying, pasting, and deleting slices

An illustration on how to use Swap Slices to copy Slice #21 and paste it before Slice #0

Example 1:

Copying a slice from the middle of the image to a new position:

For example, we have a 3D image with 43 slices and we would like to copy slice #21 to position #0. In order to do that:

  • In the Swap Slices dialog box, select slice 21 and press Crt+C (for PC) or Command +C (for Mac);
  • Navigate to the position #0, and press Ctrl+V (for PC) or Command +V (for Mac);
  • In the dialog box, you will see that Position #0 now corresponds to the slice #21;
  • To save your changes, press Swap. The new image that has 44 slices appears on your desktop.

Note: the correlation between slice number and position number would be restored in the new image after you press Swap and the new image appears on your desktop. That means that the slice #21 on the position #0 in the intermediate image shown in the dialog box would be slice #0 on the position #0 in the new image.

Please, refer to the figure on your right that shows the whole process.

What if you need to swap several slices?

In order to copy and paste a bunch of slices, select slices using the Ctrl+left mouse button combination of keys first, and then follow the same procedure described in the section above.

To move a slice to another position:

To move a slice (or slices), you need to use a combination of cut and paste.

  • Select the slice(s) and cut it using Crt+X (for PC) or Command+X (for Mac) combination of keys.
  • Navigate to the position where you want to place the slice(s) and press Ctrl+V (for PC) or Command+V (for Mac). Note that the slice appears before the position you selected.
  • Press Swap. The new image that has a bunch of slices moved to another position(s) appears on your desktop.

To delete a slice:

To delete a slice (or slices),

  • Select the slice(s) and cut it using Crt+X (for PC) or Command+X (for Mac) combination of keys.
  • Press Swap. The new image appears on your desktop.

Note: the correlation between the slice number and its position number would be restored in the new image that appears on your desktop. E.g. slice #0 - position #0, slice #1 - position #1, slice #2 - position #2, ... slice #N - position #N.

Running Swap Slices for 4D images

An illustration on how to use Swap Slices to remove slices from 0 to 31 and from 47 to 69 in a 4D image

The Swap Slices tool is also available for 4D images. If you run Swap Slices for a 4D image, it will move\copy\delete slices across all volumes. To run the tool for a 4D image, open the image of interest and then navigate to Utilities> 3D slice tools > Swap Slices. Note that the most of 3D slice tools are unavailable for 4D images, except Extract Slices, Insert Slices, Remove Slices, and Swap Slices.

Example 2:

Deleting slices from the beginning and from the end of the image volume(s)

For example, we have a 4D brain image with 16 volumes\69 slices. For our analysis we need slices from 32 to 46 only. The easiest way to extract these slices from the original image would be 1) to delete slices # 0-31 and # 47-69 from the original image and then 2) to save the updated image as a new one. One can do it by using either the Remove Slices tool or by using Swap Slices. Using Swap Slices is easier.

  • Open the 4D image.
  • Navigate to Utilities> 3D slice tools > Swap Slices.
  • Use Shift+left mouse button combination of keys to select the slice(s) from #0 to #31.
  • Cut the selected slices using Crt+X (for PC) or Command+X (for Mac) combination of keys.
  • Now, use Shift+left mouse button combination of keys to select the slice(s) from #47 to #69.
  • Cut the selected slices using Crt+X (for PC) or Command+X (for Mac) combination of keys.
  • Press Swap. The new image that has 16 volumes\14 slices appears on your desktop.

Please, refer to the figure on your right that shows the whole process.

Notes
Original image has all slices; Intermediate image - slices from 0 to 31 removed; Final image - slices from 47 to 69 (in original numeration) removed

Note 1: In the example above, you can delete slices from #0 to #31 and press Swap. In that case the result will be saved as an intermediate image that has 37 slices\16 volumes and has the same name as an original image with "_swap" added to the end of the name. Then, you can use this intermediate image to cut slices 15-37 (ones correspond to slices 47-69 in the original image) and press Swap. The result will be saved in the final image that has 14 slices\16 volumes and has the same name as the original image with with "_swap_swap" added to the end of the image name.

Note 2: The correlation between the slice number and its position number is restored each time in the new image that appears on your desktop. E.g. slice #0 - position #0, slice #1 - position #1, ... slice #N - position #N.

Swap Volumes

Swap Volumes

The Swap Volumes tool is available via Utilities > 4D Slice Tools > Swap Volumes. The tool could be run for 4D images.

Running Swap Volumes

To run the Swap Volumes tool, open an image of interest and call the tool via the Utilities > 4D Slice Tools > Swap Volumes menu. The Swap Volumes dialog box appears.

Swap Volumes dialog box

Upper menu:

For the Load and Save options, refer to Load and save profile.

Help - calls the help for this dialog box.

In the dialog box one can see 2 columns:

  • The right column is called Volume and it contains volume numbers
  • And the left column is called Index and it contains position numbers.

Volume number is the number of the volume as it encoded in the image header.

Position number is the position of the volume in the image. It shows where exactly in the image the volume is located. For the image that did not undergone any swapping the position number and the volume number are the same. E.g. volume #0 - position #0, volume #1 - position #1, volume #2 - position #2, ... volume #N - position #N.

Destination - by default the modified image will appear in the new image frame.

Swap - press Swap to move\copy\delete selected volumes and to save a modified image. The new image appears in a new image frame. You can also press S on your keyboard to run the command.

Reset - restores the values in a dialog box to the initial values. You can also press S on your keyboard to run the command.

Undo - undoes the most recent action (only). You can also press U on your keyboard to run the command.

Redo - re-does the action that was undone by Undo. You can also press d on your keyboard to run the command.

Append - adds a bunch of copied slices\volumes to the end of the image. You can also press A on your keyboard to run the command.


Copying, pasting and deleting volumes

An illustration on how to use Swap Volumes to copy volume #21 and paste it before volume #0 (position #0)

Example 3:

Copying the last volume to the position #0

For example, we have a 4D image with 16 volumes and we would like to copy volume #16 to Position #0. In order to do that:

  • In the Swap Volumes dialog box, select volume #16 and press Crt+C (for PC) or Command+C (for Mac);
  • Navigate to the position #0, and press Ctrl+V (for PC) or Command+V (for Mac);
  • In the dialog box, you will see that position #0 now corresponds to volume #16;
  • To save your changes, press Swap. The new image that has 17 volumes appears on your desktop.

Note: the correlation between the volume number and position number would be restored in the new image after you press Swap and the new image appears on your desktop. That means that the volume #16 on the position #0 in the intermediate image would be volume #0 on the position #0 in the new image.

Please, refer to the figure on your right that shows the whole process.

To swap several volumes

In order to copy and paste a bunch of volumes, select your volumes of interest using the Ctrl+left mouse button combination of keys first, and then follow the same procedure described in the Example 3 above.

To move a volume to another position:

To move a volume (or volumes), you need to use a combination of cut and paste.

  • Select the volume(s) and cut it using Crt+X (for PC) or Command+X (for Mac) combination of keys.
  • Navigate to the position where you want to place the volume(s) and press Ctrl+V (for PC) or Command+V (for Mac). Note that the volume appears above the position you selected.
  • Press Swap. The new image that has a bunch of volumes moved to another position(s) appears on your desktop.

To delete a volume:

To delete a volume (or volumes),

  • Select the volume(s) and cut it using Crt+X (for PC) or Command+X (for Mac) combination of keys.
  • Press Swap. The new image appears on your desktop.

Note: the correlation between the volume number and its position number would be restored in the new image. E.g. volume #0 - position #0, volume #1 - position #1, volume #2 - position #2, ... volume #N - position #N.

Common operations for Swap Slices and Swap Volumes

There are 5 buttons that are common for both dialogs: Swap, Reset, Undo, Redo, and Append.

To use Append:

In both dialog boxes, the Append button allows add a bunch of copied slices\volumes to the end of the image.

  • First, select and copy your slices\volumes of interest (use Crt+C - for PC, or Command+C - for Mac combination of keys to copy)
  • Then press Append. The slices\volumes would be added to the end of the image.

You can call the Append command either by pressing the button, or by pressing the A key on your keyboard.

Note: It doesn't matter which position is currently selected in the dialog box, the slices\volumes would be added to the end of the image.

Example 4:

Using Append to move slices\volumes from the middle of the image to the end:

For example, we have a 3D image with 43 slices and we would like to move slices #21- 23 to the end of the image. In order to do that:

  • In the Swap Slices dialog box, select slices #21-23 and cut them. Use Crt+X (for PC) or Command+X (for Mac);
  • Press Append;
  • In the dialog box, you could see that slices #21, 22, and 23 were added to the end of the image;
  • Press Swap. The new image appears on your desktop.

Use the similar technique to move volumes in Swap Volumes.

To use Undo and Redo:

In both dialog boxes, the Undo command allows you to undo a recent action. Once you have undone something you can change your mind and redo that step with the Redo button. You can call the Undo command either by pressing the button, or by pressing the U key on your keyboard. You can call the Redo command either by pressing the button, or by pressing the d key on your keyboard.

To use Reset:

In both dialog boxes, the Reset command restores the values in a dialog box to its initial values. You can call the Reset command either by pressing the button, or by pressing the R key on your keyboard.

To use Swap:

In both dialog boxes, the Swap command does two things:

  • It moves\copies selected slices\volumes to the chosen position(s);
  • It saves the modified image as a new image and opens it in a new image frame.

You can call the Swap command either by pressing the button, or by pressing the S key on your keyboard.

Using keyboard shortcuts

In both dialog boxes the following combinations of keys can used to perform common actions:

  • To copy slices\volumes use Crt+C (for PC) or Command+C (for Mac);
  • To paste slices\volumes use Crt+V (for PC) or Command+V (for Mac);
  • To delete\cut slices\volumes use Crt+X (for PC) or Command+X (for Mac);
  • To undo the last performed action use Crt+Z (for PC) or Command+Z (for Mac), or press U key on your keyboard;
  • To redo the last performed action or press d key on your keyboard;
  • To reset the dialog box values, press R key on your keyboard;
  • To use Append, press A key on your keyboard;
  • To use Swap, press S key on your keyboard.

New image name

The new image (the one that was saved after swapping) has the same name as the original image plus _swap_ addition to its name. For example, if the initial image name was t2-vol-tr800, the new image after undergoing a single swap operation will have a name t2-vol-tr800_swap. If you apply another swap operation to the t2-vol-tr800_swap image, the new image will have the name t2-vol-tr800_swap_swap (with 2 swaps).

See also: