Key words

1 Introduction

The potential of magnetic resonance imaging (MRI) for the diagnosis and monitoring of renal disease remains largely untapped. Functional renal MRI promises access to a wide range of (patho)physiologically relevant parameters via techniques such as blood oxygenation sensitive T2*-mapping (aka blood oxygenation level-dependent MRI, BOLD ), perfusion measurement by arterial spin labeling (ASL ), and diffusion weighted imaging (DWI ). Insights into microstructural changes can be obtained with DWI and T1-mapping, for example to probe for renal fibrosis. Emerging techniques including pH-mapping via chemical exchange saturation transfer (CEST) and sodium (23Na) imaging complement the renal MRI portfolio. For quantitative comparison of results, representative values must be extracted from the parametric maps obtained with any of these MRI techniques. To improve reproducibility of results this should be done based on regions-of-interest (ROIs) that are clearly and objectively defined.

Semiautomated subsegmentation of the kidney in MRI represents a simple but very valuable approach for the quantitative analysis of imaging parameters in multiple ROIs that are associated with specific anatomic locations, for example, the distinct layers: cortex, outer medulla, and inner medulla. Thereby, it facilitates comparing MR parameters between different kidney regions, as well as tracking changes over time. Here we use the term subsegmentation in order to make a clear distinction between segmenting the kidney into smaller subregions and the identification of the kidney organ borders within an image, for which commonly the term segmentation is used.

In this chapter we provide detailed step-by-step instructions for two recently proposed subsegmentation techniques [1, 2], which are suitable for kidneys of small rodents: (1) the placement of ROIs in cortex, outer and the inner medulla based on typical kidney morphology (used in [1, 3,4,5,6,7,8]) and (2) the division of the kidney into concentrically oriented layers (used in [2, 9,10,11,12,13]). They work independent of the actual image contrasts or parameter map values and hence are well suited for a wide range of MRI mapping techniques. Both techniques allow for the exclusion of one or several regions in the kidney from the analysis, for example regions that show obvious image artefacts. Changes in kidney size are accommodated for by both techniques, but results should be treated with due caution if the relative sizes of the renal layers are significantly different from naive healthy kidneys or change throughout the experiment.

The first method described here is the Segmentation of Morphology-Based Renal Regions-of-Interest (SOMBRERO) [1]. Quantitative histomorphological data on the dimensions of the renal layers were obtained from a number of freshly excised kidneys of adult male rats, where anatomical structures were identified to be distributed in certain proportions. The percentages referring to the corresponding locations exclude the rather broad (and in case of the cortical–medullary border zone undulating) transition regions among the layers that are prone to partial volume effects. The percentages are adapted to MRI images by determining a standardized location, length, width and angle of the kidney in the image. Subsequently, ROIs at anatomical locations such as the cortex, outer medulla, and inner medulla are returned automatically in form of masks. These masks can then easily be applied to the user’s parameter maps.

The strength of this technique is that it creates ROIs whose positions have been carefully chosen to provide representative values for the renal cortex, outer medulla and inner medulla, leaving a generous “buffer zone” at the transition regions between the renal layers. Also, access to five (or three) ROIs in each layer allow assessment of inter-layer and intra-layer variability. Differences between the parameters in the three renal layers can be expressed as ratios, such as T2*(cortex)/T2*(outer medulla). The transition regions between the renal layers are not accessible with this approach at present, but such a feature could be included without difficulty in the future, even by the user. ROI locations have been defined for rat kidneys in coronal view (with respect to the kidney). However, this method is in principle applicable to mouse and rat kidneys in axial, sagittal, and coronal view. An extension to other orientations or mice would only require some additional careful morphometric measurements to define the relative ROI positions.

The second technique is the multiple-layer concentric objects segmentation (MLCO; for human MRI proposed as 12-layer concentric objects, TLCO) [2, 9]. A series of concentrically oriented layers is generated after a manual retracing of the outline of the kidney in the respective MR image. The desired number of concentric objects (COs) can be freely chosen by the user, although most publications have used twelve layers in humans thus far.

This technique was developed for human kidney MRI; although the COs do not refer to specific anatomic locations, they approximately reflect the layered structure of the kidney through their concentric nature. This makes it suited for MRI of rodent kidneys, whose simpler anatomic structure is better represented by the concentric layers than that of the human kidney. While the outermost and innermost COs are straightforward to interpret and are generally considered as a proxy of respectively cortex and medulla, a clear association of the intermediate concentric objects with the renal layers remains challenging, in particular, because the broad transition zones and, thereby, probable partial volume effects are neglected. Differences between the parameters in the three renal layers can only be indirectly expressed by the slope of the curve when plotting the COs’ mean values against their position. This technique is applicable to mouse and rat kidneys in axial, sagittal, and coronal view (with respect to the kidney). One of its strengths is its applicability to human kidneys. A direct comparison between human results and those from rodent kidneys would, however, require a carefully calibrated conversion, due to the morphological differences.

Notwithstanding their limitations, both kidney subsegmentation techniques are very valuable semiautomated tools for the quantitative analysis of imaging parameters, specifically for comparing MR parameters between groups, between different kidney regions and monitoring changes over time. Use of these objectively defined ROIs (rather than manually drawn ROIs) should help to improve reproducibility and comparability of results in future studies.

This chapter is part of the book Pohlmann A, Niendorf T (eds) (2020) Preclinical MRI of the Kidney—Methods and Protocols. Springer, New York.

2 Materials

2.1 Software Requirements

2.1.1 Essential Tools

The SOMBRERO method is provided in Python (3.6) programming language. It has been implemented and tested using the following software, which is available for macOS 10.14.5 (used for development), Windows and Linux operating systems.

  1. 1.

    Spyder 3.2.4, installed through Anaconda (https://www.anaconda.com), which is open-source.

The MLCO method requires the following software:

  1. 2.

    The MATLAB® programming environment (MathWorks, Natick, MA, USA, https://www.mathworks.com/products/matlab.html). It may also be possible to use the open-source alternative Octave (https://www.gnu.org/software/octave/), but this has not been tested and may require some adaptations in the MLCO toolbox.

2.1.2 Toolboxes

The provided software for SOMBRERO requires the installation of the following packages: numpy, matplotlib, cv2, math, pydicom, os, and pickle.

These can be conveniently installed one-by-one through the Anaconda Navigator for Windows. For Linux or MacOS the following line in the terminal will install all them at once:

pip install numpy matplotlib cv2 math pydicom os pickle

2.1.3 Software

SOMBRERO: The software is provided online at GitHub: https://github.com/lriazy/sombrero/

MLCO: The software is provided online at GitHub: https://github.com/bmilani/conObj

2.2 Source Data: Format Requirements

2.2.1 Imaging Planes

Common MRI imaging planes are sagittal, coronal, and axial slices as displayed in Fig. 1. For the sake of this tutorial we will focus on coronal slices. Other imaging planes are possible for these segmentations as well (see Note 1).

Fig. 1
figure 1

Typical MR imaging planes and their resulting kidney shapes. The coronal, axial, and sagittal planes do not correspond to the scanner coordinate system, but instead are defined with respect to the double-oblique spatial orientation of the kidney. “C” stands for crescent and “D” doughnut

2.2.2 Input Requirements

In this chapter, all input files are assumed to be Dicoms. However, any way to import an image as a matrix to Matlab or NumPy array to Python will work equivalently.

3 Methods

3.1 Segmentation of Morphology-Based Renal Regions-of-Interest (SOMBRERO)

3.1.1 Settings

In order to display interactive plots, make sure your graphics backend is set on “automatic.”

This can be looked up in Preferences > IPython console > Graphics > Graphics backend.

3.1.2 Loading Images

  1. 1.

    Open the script roirect.py, which is executed cell-by-cell. Running a cell can be done by a button or by pressing CTRL + ENTER.

  2. 2.

    The images are loaded by the line:

    im = pydicom.dcmread('EnIm1.dcm')

    in the script. Modify 'EnIm1.dcm' to be the path to your dicom file. In this case, the file is located in the same directory as the script. Therefore the filename is sufficient.

3.1.3 Definition of Bounding Box

  1. 1.

    Execute the first cell in roirect.py.

  2. 2.

    Drag on the image to draw a new rectangle (Fig. 2a).

  3. 3.

    Use the edge markers to adjust the height and width of the rectangle

  4. 4.

    Shift the rectangle using the central marker.

  5. 5.

    Tip the rectangle using one of the edge markers (Note: A finer adjustment of the angle can be done by pressing the UP and DOWN buttons).

  6. 6.

    Press ENTER to end the adjustments and proceed.

Fig. 2
figure 2

(a) Manual selection of the kidney with the rectangle tool. (b) Cropped and straightened kidney image with reference lines. The red boxes are located in the cortex, the yellow box in the outer medulla and the blue box in the inner medulla. (c) Display of the successful selection of two border points (in green) at the intersection of the kidney border and the diagonal line. (d) The ROIs after transformation to the locations in the original image (without cropping or other processing). (e) The final mask of ROIs as an image of the same size as the original image with coded regional masks

3.1.4 Diagonal Boundary Selection

  1. 1.

    A new window opens up automatically (Fig. 2b).

  2. 2.

    Mark two points marking the end of the kidney on the black diagonal lines.

  3. 3.

    The resulting image should look like Fig. 2c).

3.1.5 Generation of Mask for Imaging Series

  1. 1.

    Execute the next section to transform the morphologic ROIs back to their locations in the original image (Fig. 2d).

  2. 2.

    Execute the next section to generate and visualize the variable roimask, which contains numbered masks for each ROI (Fig. 2e).

3.1.6 Saving Mask

  1. 1.

    Generate a path to the file by connecting the path (path =“ and filename=’1’ will save the file 1.pickle in the current folder).

    pfile = os.path.join(path,filename+'pickle')

  2. 2.

    Write the file using the following commands:

    with open(pfile,'wb') as f:

    pickle.dump([S, roimask], f)

3.1.7 Loading Mask

  1. 1.

    Generate a path to the file by connecting the path just as in saving the file:

pfile = os.path.join(path,filename+'pickle')

  1. 2.

    Read the file into the variables S and roimask:

S, roimask = pickle.load(open(pfile,"rb"))

3.2 Multilayer Concentric Objects (MLCO) Segmentation

Given the character of in-house developed programs, the MLCO toolbox allows the user the freedom and obligation to specify all details exactly. Subheadings 3.2.13.2.4 describe essential steps, where any of the proposed options have to be chosen. Finally, Subheading 3.2.5 shows an example for each choice made as in the preceding sections and composes a script, which is ready to run.

3.2.1 Load an Image or a List of Images in a Matlab Array

  1. 1.

    Open the matlab script called demo_script.m.

  2. 2.

    Note that you can execute a cell of a matlab script by pressing CTRL + ENTER.

  3. 3.

    Load a list of images by executing for example the following line:

    myImageList = conObjDicomRead('Dir' ,'C:\Users\conObj\myGRE\');

  4. 4.

    This loads the image list stored in C:\Users\conObj\myGRE\.

  5. 5.

    The variable myImageList, is now a three-dimensional array containing a list of matrices that each corresponds to a gray scale image.

  6. 6.

    You can visualize this image list by executing the line

    conObjImage(myImageList);

    This function plots the first image in the image stack. If you would like to display the mean of all images. The file has to be opened and modified. Line 41 has to be modified from

    imagesc(argIm(:,:,curImNum));

    to

imagesc(mean(argIm(:,:,:),3))

  1. 7.

    You can navigate through the images with the up and down arrow of your keyboard.

3.2.2 Defining the Number of Layers

In order to realize the concentric object technique, you have to choose a mask-number, which is the number of masks that will patch the chosen segmented area of you images. We also call this number the “number of layers” and we gave the name nLayers to this number in our script (see Note 2). If you want 9 layers, execute the line

nLayers = 9;

The number of layers is inevitably limited by the image resolution. For experimental MR, 9 layers are recommended, whereas MR images of human kidneys were usually divided into 12 layers.

3.2.3 Segmenting the Area of Your Choice in the Image

In the following, the segmentation of “C”-shaped kidney slices from MR images will be described. This applies to coronal (Fig. 3) and axial (Fig. 4) slices as shown in Fig. 1.

  1. 1.

    Execute the line

    [myBound_ext, myBound_int] = conObjBound_C(myImageList);

  2. 2.

    A matlab figure appears displaying the first image stored in myImageList.

  3. 3.

    Navigate through the images with the up and down arrow of your keyboard.

  4. 4.

    Adjust the contrast by pressing on CTRL+D and fix the change by pressing on CTRL+F.

  5. 5.

    By clicking on the picture, you can manually segment the area of your choice (Fig. 3a).

  6. 6.

    Note that pressing the key ESC allows you to reset your selection. You can also zoom in the picture with the available Matlab tools. If any problem appears during this manual segmentation , pressing the key ESC often solves the problem!

  7. 7.

    Double click on the picture to close the polygon. You can still modify the position of its vertices interactively on the picture (Fig. 3a).

  8. 8.

    When you are finished, double-click inside the polygon.

  9. 9.

    The contour of your segmentation will now appear in white (Fig. 3b).

  10. 10.

    Click near the white line at two different locations to indicate where the separation between the inner part and the outer part of the contour should occur. (Note: You do not need to press exactly on the white line because the program will choose the location on the white line that is the closest to your click.) (Fig. 3b)

  11. 11.

    The inner and outer part of the contour appear now in blue and red respectively (Fig. 3c).

  12. 12.

    You can now close the figure. The polygon of the outer contour is now stored in the variable myBound_ext and the polygon of the inner contour is now stored in myBound_int.

Fig. 3
figure 3

(a) Closed manual contour of the kidney. Modification of the contour at the blue points is still possible at this stage. (b) The contour of the kidney turns white, after the contour is finished. The required input of two points describe the inner and outer borders. (c) After the two points have been entered, the inner and outer contour can be automatically separated into blue and red contours. (d) Output of the finished MLCO procedure

Fig. 4
figure 4

(a) Manual contouring of the outer kidney boundary in the MLCO method. (b) The contour of the kidney turns white, after the contour is finished. (c) After the two points have been entered, the inner and outer contour can be automatically separated into blue and red contours. (d) Output of the finished MLCO procedure

The same procedure can be applied for axial slices (Fig. 4). We describe in the following how to segment an area that contains a hole. The procedure is very similar to the previous one but the function conObjBound_D has to be used instead of conObjBound_C (C for crescent and D for doughnut).

  1. 1.

    First execute the line

    [myBound_ext, myBound_int] = conObjBound_D(myImageList);

  2. 2.

    As previously, segment manually the area of your choice (Fig. 5a) and double-click in the polygon to validate it. The contour of the polygon is now white and you can choose another closed polygon that has to lie inside the first one (Fig. 5b).

  3. 3.

    Once the second area is segmented, double-click inside it such that its polygon also appears in white (Fig. 5c).

  4. 4.

    As previously, you have to indicate which contour is the outer one and which contour is the inner one. For that purpose, click first near the outer contour and then click near the inner one. But the two location you click on must be approximately on the same radial line (as on Fig. 5d) to allow the algorithm to work correctly.

  5. 5.

    Once the two location are chosen, the outer and inner contour appear in red and blue respectively (Fig. 6a). This closes the step of the segmentation .

Fig. 5
figure 5

(a) Outer contour for the “D”-shaped kidneys. (b) Entered contour in white. (c) Inner contour added manually, which is different from the previous “C”-shape procedure. (d) The required input of two points describe a radial line

Fig. 6
figure 6

(a) Inner and outer contour can again be identified after two points are entered. (b) The finished output from the MLCO method for “D”-shaped kidneys. (c) Exclusion of regions. (d) Result from MLCO method after excluding the regions specified in (c)

3.2.4 Build the List of Masks That Realizes the Concentric Object Technique

  1. 1.

    Execute the following line:

    myCO_mask = conObjMask(myImageList, myBound_ext ,myBound_int,.nLayers);

  2. 2.

    You can visualize the masks with the command

    conObjImage(myCO_mask);

  3. 3.

    Browse through the different masks with the up and down arrow of the keyboard. Alternatively, you can visualize the list of masks by executing

    conObjMaskImage(myCO_mask)

    or

    conObjMaskImage(myCO_mask, 'jet')

    The last line results for example in Figs. 3d and 4d for the segmentation in the crescent shape and in Fig. 6b) for the segmentation in the doughnut shape.

3.2.5 Basic Script for Applying the Concentric Object Technique

Assuming the location of the images to be in the folder 'C:\Users\conObj\myGRE\', a basic script could look as follows:

myImageList = conObjDicomRead('Dir' ,'C:\Users\conObj\myGRE\');

[myBound_ext, myBound_int] = conObjBound_C(myImageList);

myCO_mask = conObjMask(myImageList, myBound_ext ,myBound_int,... nLayers);

3.2.6 Exclusion of Regions

This part describes multiple possibilities, which are optional for modifying the list. The only steps required are the first and the second.

  1. 1.

    Create an object of the class conObjExclusion.m in the conObj folder by executing: myExclusion = conObjExclusion;

  2. 2.

    Manually segment some region of the image to exclude from the analysis and to store these exclusion regions in the object myExclusion. For that purpose, execute: myExclusion.stack(myImageList);

  3. 3.

    A figure appears.

  4. 4.

    Segment the area of your choice.

  5. 5.

    Double-click to close the polygon and double-click again in the polygon to validate it. (You can execute steps 25 as many times as you want to add new exclusion regions.)

  6. 6.

    Execute myExclusion.show(myImageList);

    to visualize all the exclusion mask that are in the object myExclusion (Fig. 6c).

  7. 7.

    Execute myExclusion.remove[2];

    to remove the exclusion mask number 2.

  8. 8.

    Execute myExclusion.clear;

    to empty the object myExclusion.

  9. 9.

    To construct a new list of masks from the previous list of masks myCO_mask but excluding the region stored in the object myExclusion, simply execute

    myCO_mask_new = myExclusion.crop(myCO_mask);

  10. 10.

    The new list of masks myCO_mask_new can be displayed by executing the following line conObjMaskImage(myCO_mask_new);

    which results in Fig. 6d.

4 Notes

  1. 1.

    The orientation of the kidney was assumed to be coronal throughout this chapter. However, the MLCO method does not refer to specific anatomical locations and can therefore be used in any of the cases displayed in Fig. 1. The SOMBRERO method can potentially be used in other planes as well but would need new percentage values from kidney histology as a reference.

  2. 2.

    For human renal MRI the use of 12 layers was proposed [2]. For rats and mice another number of layers may be more suitable. This also depends on the spatial resolution that can be achieved with that particular MRI technique and available hardware, because it would probably not make much sense to have layers with a width of less than one (noninterpolated) pixel. As a default we recommend to use the proposed number of 12 layers.