replaceSlice
Description
replaces the voxel values for one slice, medVolUpdated
= replaceSlice(medVol
,slice
,direction
,sliceValues
)slice
, of the medicalVolume
object medVol
along the specified direction,
direction
. The replaceSlice
function returns a
new medicalVolume
object with the updated values, specified by
sliceValues
.
Examples
Replace Slice in Medical Image Volume
Replace one slice of a medical image volume created using a chest CT volume saved as a directory of DICOM files. The CT volume is part of a data set containing three CT volumes. The size of the entire data set is approximately 81 MB. Download the data set from the MathWorks® website, then unzip the folder.
zipFile = matlab.internal.examples.downloadSupportFile("medical","MedicalVolumeDICOMData.zip"); filepath = fileparts(zipFile); unzip(zipFile,filepath)
Specify the directory of DICOM files for the first CT volume in the data set.
dataFolder = fullfile(filepath,"MedicalVolumeDICOMData","LungCT01");
Create a medical volume object for the CT volume.
medVol = medicalVolume(dataFolder);
Extract the second slice in the transverse direction. The size of the extracted slice, X
, is 512-by-512.
[X,position,spacings] = extractSlice(medVol,2,"transverse"); whos X
Name Size Bytes Class Attributes X 512x512 524288 int16
Specify a new 512-by-512 matrix to replace the extracted slice.
newX = ones(512);
Create a new medicalVolume
object that replaces the extracted slice with the new slice.
medVolUpdated = replaceSlice(medVol,2,"transverse",newX);
Input Arguments
medVol
— Medical volume
medicalVolume
object
Medical volume, specified as a medicalVolume
object.
slice
— Slice index
positive integer scalar in range [1, numSlices]
Slice index, specified as a positive integer scalar in the range [1,
numSlices], where numSlices is the number of
slices in the volume along the direction specified by
direction
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
direction
— Direction along which to update slice
"coronal"
| "sagittal"
| "transverse"
Direction along which to update the slice information, specified as
"coronal"
, "sagittal"
, or
"transverse"
.
Data Types: char
| string
Output Arguments
medVolUpdated
— Medical volume with updated slice
medicalVolume
object
Medical volume with updated slice, returned as a medicalVolume
object.
Version History
Introduced in R2022b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)