\documentclass{midl} % Include author names
%\documentclass[anon]{midl} % Anonymized submission

% The following packages will be automatically loaded:
% jmlr, amsmath, amssymb, natbib, graphicx, url, algorithm2e
% ifoddpage, relsize and probably more
% make sure they are installed with your latex distribution










%% Stylefile to load YCVIU template

%% The amssymb package provides various useful mathematical symbols
\usepackage{amssymb}
\usepackage{latexsym}

\usepackage{lineno,hyperref}
\modulolinenumbers[5]
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{xcolor,cancel,mathrsfs,amscd}
%\usepackage{subfigure}
\usepackage{subfig}
%\usepackage{subcaption,graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{subfig}
\usepackage{color}
\usepackage{float}
\usepackage{url}
\usepackage{breakcites}
\usepackage{array}

\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}

\usepackage[nameinlink,capitalize]{cleveref}

% \usepackage[table]{xcolor} http://ctan.org/pkg/xcolor

\usepackage[T1]{fontenc}% optional T1 font encoding

\usepackage{supertabular}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage[graphicx]{realboxes}
\usepackage{pdflscape}
\usepackage{amsmath}
\usepackage{ulem}


\usepackage[cmintegrals]{newtxmath}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\usepackage{multirow}


\definecolor{myblue}{rgb}{.0,.0,.8}
\newcommand{\veronika}[1]{\textcolor{myblue}{Veronika: #1}}
\newcommand{\Rosana}[1]{\textcolor{purple}{Rosana's comment: #1}}
\definecolor{myg}{rgb}{.0,.3,0}
\newcommand{\caro}[1]{\textcolor{myg}{Caro: #1}}


\definecolor{normal}{rgb}{.0,.0,.0}
\definecolor{myred}{rgb}{.8,.0,.0}
\definecolor{myblue}{rgb}{.0,.0,.8}

\newcommand{\todo}[1]{\textcolor{myred}{TODO: #1}}
\newcommand{\added}[1]{\textcolor{myblue}{#1}}

\newcommand{\PH}[1]{\textcolor{myblue}{{\bf PH:} #1}}







\usepackage{multicol}

\usepackage{mwe} % to get dummy images




\midlauthor{\Name{Rosana \snm{El Jurdi} \nametag{$^{1,2}$}} \Email{rosana.el-jurdi@univ-rouen.fr}\\
\Name{Caroline  \snm{Petitjean} \nametag{$^{1}$}} \Email{caroline.petitjean@univ-rouen.fr}\\
\Name{Paul \snm{Honeine} \nametag{$^{1}$}} \Email{paul.honeine@univ-rouen.fr}\\
\Name{Veronika \snm{Cheplygina} \nametag{$^{4,5}$}} \Email{v.cheplygina@tue.nl}\\
\Name{Fahed \snm{Abdallah} \nametag{$^{2,3}$}} \Email{fahed.abdallah76@gmail.com}\\
\addr $^{1}$ Normandie Univ, INSA Rouen, UNIROUEN, UNIHAVRE, LITIS, Rouen, France\\
\addr$^{2}$ Universit\'e Libanaise, Hadath, Beyrouth, Liban \\
\addr$^{3}$ ICD, M2S, Universit\'e de technologie de Troyes, Troyes, France \\
\addr $^{4}$ Computer Science Department, IT University of Copenhagen, Denmark \\
\addr $^{5}$ Medical Image Analysis group, Eindhoven University of Technology, Eindhoven, The Netherlands \\
}


\title[A Surprisingly Effective Perimeter-based Loss for Medical Image Segmentation]{A Surprisingly Effective Perimeter-based Loss for Medical Image Segmentation}
\jmlryear{2021}
\jmlrworkshop{Full Paper -- MIDL 2021}

% Rosana :::
% A Surprisingly Effective Perimeter Constraint loss for Medical Image Segmentation
% A Surprisingly Effective Perimeter Constraint loss for Medical Image Segmentation
% A Surprisingly Effective Perimeter Constraint loss for Border Irregularity in Medical Image Segmentation 

% Caro :::
%A perimeter constraint loss based on a gradient proxy  for Medical Image Segmentation
%A length constraint loss based on a morphological gradient for Medical Image Segmentation
%A perimeter constraint loss based on (network) built-in gradient for Medical Image Segmentation


 % Use \Name{Author Name} to specify the name.
 % If the surname contains spaces, enclose the surname
 % in braces, e.g. \Name{John {Smith Jones}} similarly
 % if the name has a "von" part, e.g \Name{Jane {de Winter}}.
 % If the first letter in the forenames is a diacritic
 % enclose the diacritic in braces, e.g. \Name{{\'E}louise Smith}

 % Two authors with the same address
%   \midlauthor{\Name{Rosana {El Jurdi} \nametag{$^{1,2}$}} \Email{rosana.el-jurdi@univ-rouen.fr} \\ \and
%   \Name{Author Name2} \Email{xyz@sample.edu}\\
%   \addr Address}
% \\
% \addr $^{1}$ }
% \addr $^{2}$ \textit{Lebanese University, Beirut, Lebanon} \\
 % Three or more authors with the same address:
 % \midlauthor{\Name{Author Name1} \Email{an1@sample.edu}\\
 %  \Name{Author Name2} \Email{an2@sample.edu}\\
 %  \Name{Author Name3} \Email{an3@sample.edu}\\
 %  \addr Address}


% Authors with different addresses:
% \midlauthor{\Name{Author Name1} \Email{abc@sample.edu}\\
% \addr Address 1
% \AND
% \Name{Author Name2} \Email{xyz@sample.edu}\\
% \addr Address 2
% }

%\footnotetext[1]{Contributed equally}
\begin{document}

\maketitle

\begin{abstract}
%\input{abstract_rosana}
\input{abstract_veronika}

% \Rosana{I am not sure we shoudl get into too much details of max pooling and ReLus }

% \textcolor{red}{are you sure? is it the case for both Kervadec and Karimi ? at least Kervadec does not seem computationally expensive....}.


% \Rosana{Kervadecs method is not computationally expensivve but it suffers from local solutions ....kervadec said so in his paper !that is why they used the dynamic training strategy}

%Deep convolutional neural networks (CNNs) have achieved state-of-the-art results in medical image segmentation. Still, some anatomically aberrant segmentation may be observed, with holes or inaccuracies near the object boundaries, in cases of irregular shapes, lack of contrast, or noise. One solution to avoid this artefact that has recently been investigated is to add constraint in the loss function, such as spatial information or knowledge. In this work, we focus on loss constraint on the object boundaries. Contour-based losses  exploit distance maps in order to conducts point-by-point optimization between ground-truth and predicted contours. Such losses are complex in nature and computationally too expensive. As a result, they are often susceptible to local solutions and vanishing gradient problems. The problem becomes more challenging given organs with non-convex shapes or border irregularities. This work proposes to constrain the length of the object to be segmented to match the length of the ground-truth segmentation map. The originality is to compute the object perimeter thanks to a soft approximation of the contour of the probability map: the contour is estimated with a morphological gradient that leverages leveraging the network architecture, i.e. the min- and max-pooling layers and ReLu operations.
%Thus, instead of point-by-point minimization, the mean squared error between the sums of the over all ground-truth vs. predicted contours is optimized.
%This soft optimization of contour boundaries allows the network to take into consideration border irregularities within organs while still being efficient and fast. To validate the performance of the proposed loss, experiments are conducted on three public datasets (the spleen and hippocampus datasets  from the Decathlon challenge and the ACDC dataset, a cardiac cine-MR dataset dedicated to segmentation of three cardiac structures). Results show that the proposed method outperforms state-of-the-art boundary losses for both single and multi-organ segmentation.

\end{abstract}
\smallskip
\begin{keywords}
Medical Image Segmentation, Convolutional Neural Networks, Prior-based Losses, perimeter length Constraint.
\end{keywords}

\section{Introduction}

\label{sec:introduction}
Medical image segmentation consists of making per-pixel predictions in an image. The segmentation process is a key step in assisting early disease detection, diagnosis, monitoring treatment and follow up. Segmentation approaches based on convolutional neural networks (CNNs) are leading approaches in the field. However, the segmentation results they provide often suffer from anatomical errors, with holes, voids or high inaccuracies close to organ boundaries \cite{ACDC}. Recent works aim to alleviate this issue by integrating additional boundary or contour-based losses into the CNN \cite{Kervadec2019_BoundaryLoss, karimi_reducing_2019,caliva2019_MIDL,yang2019_MIDL}. In fact, \cite{Kervadec2019_BoundaryLoss, karimi_reducing_2019, caliva2019_MIDL} show that contour-based losses could allow for more anatomical plausible segmentation when trained independently or in conjunction with a regional loss such as the soft Dice approximation or the cross-entropy. Contour-based losses often aim to minimize directly or indirectly the one-to-one correspondence between points on the predicted and label contour. Therefore, despite their significance, these losses are rather complex in nature and are characterized by hard gradients and high computational cost. Moreover, they often exploit distance maps to represent the change between predicted and ground-truth boundaries \cite{Kervadec2019_BoundaryLoss} which in turn tend to underestimate the contour-to-contour distances given that the closest point is chosen systematically. As a result, the segmentation model may suffer from trivial local solutions \cite{Kervadec2019_BoundaryLoss} or vanishing/exploding gradients. The problem becomes particularly challenging when the anatomical object under consideration has a complex shape with concavities or border irregularities.

In this work, a novel contour-based loss is proposed, which targets to constrain the perimeter or contour length of the organ to be segmented. %Thus, instead of minimizing the inter-distance within each point on the predicted vs. label contour \cite{karimi_reducing_2019}, the error between the sum of each of the predicted and label contours is rather considered. 
Inspired by methods of \cite{clDice2020}, we extract contour maps from both the ground-truth and predicted segmentation maps. We then minimize the error between the predicted and ground-truth perimeter lengths by considering the sum over each respective contour via a mean squared error. We argue that by targeting the perimeter length rather than the point-by-point distance, the model will be able to take into consideration border irregularities, such as sudden corners or curvatures within organ shapes. In doing so, it avoids shrunken or expanded anomalies.
Moreover, the simplicity of the proposed loss, being the mean squared error between two lengths, may play an important role in allowing the network to learn at a faster rate and with high efficiency.

The proposed loss is evaluated across three public datasets of different tasks and modalities. The spleen dataset is from the Medical Segmentation Decathlon and consists of CT images that target spleen segmentation. The ACDC dataset contains cardiac magnetic resonance images (MRI) and the goal is to segment the two ventricles and the myocardium. The Decathlon hippocampus dataset consists of segmenting two neighboring small structures in MRI images. These public datasets were chosen in such a way that the structures to be segmented are characterized by particular shapes and non-convexity as is shown in \figurename~\ref{Datasets}.
%For instance, the spleen dataset has extreme curves and has a variety in shape and size \figurename~\ref{fig:spleen_ds}. In the  ACDC dataset, the LVC consists of holes that encompass the simple circular shaped MYO and that is in very close proximity to the RVC. On the other hand, the RVC resembles the spleen shape in its extreme curvatures and non-convex nature \figureautorefname~\ref{Datasets}. Finally, we have considered the Decathlon hippocampus dataset , which consists of small neighboring tissues in the brain for generalizability purposes i.e. to test the performance of the proposed loss against a non-organ medical datasets \figureautorefname~\ref{fig:hippo_ds}.
We test the significance of the proposed loss in both a single-organ segmentation setting and a multi-organ segmentation setting.
%We test the significance of the proposed loss in two settings: a single-organ segmentation setting that targets the spleen and each of the heart structures of the ACDC dataset independently; and a multi-organ segmentation setting for simultaneous segmentation of the ACDC heart structures and the two hippocampus tissues.
Surprisingly, despite the simplicity of the proposed loss, it outperforms state-of-the-art contour losses for organs with non-convex shapes and maintains segmentation performance for simple shapes such as circles and holes. Moreover, the proposed loss allows for accurate delineation of common boundaries between neighboring organs in the multi-organ segmentation framework.

\begin{figure*}[t!]
  \subfloat[][Spleen]
  {
	\begin{minipage}[c]{
	   0.3\textwidth}
	   \centering
	    \includegraphics[width=5cm,height=2.5cm]{img/spleen.jpeg} \label{fig:spleen_ds} 
	\end{minipage}
	}
 \subfloat[][ACDC]
  {
	\begin{minipage}[c]{
	   0.3\textwidth}
	   \centering
	    \includegraphics[width=5cm,height=2.5cm]{img/acdc.jpg} \label{fig:acdc_ds} 
	\end{minipage}
	}
	 \subfloat[][Hippocampus]
  {
	\begin{minipage}[c]{
	   0.3\textwidth}
	   \centering
	    \includegraphics[width=5cm,height=2.5cm]{img/hippo.jpeg} \label{fig:hippo_ds} 
	\end{minipage}
	}
\caption{Sample images from the 3 datasets with ground-truth regions overlaid. (a) Spleen is in green, (b) right ventricle is  in blue, left ventricle is yellow and myocardium in green, (c) brain hippocampus with outer (H1) and internal (H2) tissues in   pink and green resp.} \label{Datasets}
\end{figure*}

The rest of the paper is organized as follows. Section \ref{relatedwork} provides a brief overview of the state-of-the-art contour-based losses. Section \ref{proposed} elaborates on the proposed loss. Section \ref{expSetting} presents the datasets as well as the experimental settings. Section \ref{results} analyzes model performance on the three datasets. Finally, Section \ref{conclusion} concludes with future works and perspectives.

\section{Related Work}
\label{relatedwork}

In the literature, many research works have attempted to impose constraints at the level of the loss function in segmentation networks. One way to do so is to directly exploit the ground-truth map in order to enhance specific geometric properties, e.g. via distance map or Laplacian transform %ay be anatomical prior-based , which targets the topology or size of the organ or maybe distance-based i.e.
%involving ground-truth transformations that reveal geometric properties of the data via distance maps for example or Laplacian transforms 
\cite{jurdi2020highlevel, bohlender2021survey}. In this regard, two major contributions are the boundary loss, proposed by \cite{Kervadec2019_BoundaryLoss}, and the Hausdorff loss, proposed by \cite{karimi_reducing_2019}. Both works tackle the problem of contour optimization between ground-truth and predicted segments, to increase anatomical plausibility in their respective deep learning segmentation models. However, whereas  \cite{karimi_reducing_2019} conduct a direct point-by-point optimization of the predicted and ground-truth contours, \cite{Kervadec2019_BoundaryLoss} derive, through \cite{Boykov2001} graph theories, an equivalent term that fine-tunes the probability distribution via ground-truth distance maps. In this way, \cite{Kervadec2019_BoundaryLoss} alleviate the high computational load demonstrated by \cite{karimi_reducing_2019}, resulting from the online computation of the predicted distance maps per each iteration and for all images in the dataset.
Instead of weighting the probability distributions as in \cite{Kervadec2019_BoundaryLoss}, \cite{caliva2019_MIDL} exploit distance maps as weighing factors for a cross-entropy loss term in order to improve extraction of shape bio-markers and enable the network to focus on hard-to-segment boundary regions. As a result, they give more weight to pixels lying in close proximity of the segmented anatomical objects than those that are far away. Instead of distance maps, \cite{yang2019_MIDL} exploit Laplacian filters in order to develop a boundary enhanced loss term that invokes the network to generate strong responses around the boundary areas of organs while producing a zero response given pixels that are farther from the peripheries. In the same context, \cite{Arif2018} extend the regular cross-entropy term with an average point to curve Euclidean distance factor between predicted and ground-truth contours in order to allow the network to take into consideration shape specifications of segmented structures. 

\section{Proposed Method}\label{proposed}


Many works in the field base their losses on distance maps in order to integrate geometric and location prior into the learning framework. Alternatively, we exploit contour maps produced via a combination of non-trainable max and min pooling layers.


%We should note that we do not assume that utilization of contour map is more efficient than the distance map , which are widely known and extensively adopted in the field. However, we hypothesize that using exact indicators of positions via the proposed method may have direct, positive effect on system performance. Another key difference between these losses and ours is that these losses aim to minimize directly or indirectly the one-to-one correspondence between each point on the predicted and label contour. On the other hand, the proposed loss sums over the number of pixels constituting the predicted and ground-truth contour. The simplicity and differentiability of the proposed loss allows the network to train efficiently and at a faster rate.

\subsection{Implementation of the contour function  $\digamma$}\label{cotour_function}
Implementation of the contour function  $\digamma$  is conducted via subtracting the erosion of the segmentation map from the dilation of the eroded map as shown in \figurename~\ref{fig:Contour_function}. Dilation and erosion of the predicted and ground-truth maps are carried out via max and min pooling layers, followed by a ReLu layer. 
% whose objective is to eliminate pixels that were generated by dilation but are not part of the initial segmentation map. 
We note that $\digamma$ can extract the contour of any image, whether it is a binary or a probability map. Hence, one can consider the contour function as a simple morphological gradient that can accommodate back-propagationin CNN training. The contour function $\digamma$ is inspired by works of \cite{clDice2020} that exploit this extraction strategy in order to integrate skeletonization constraints at the level of the loss function for tabular and vessel segmentation. \cite{clDice2020} repeated this extraction process each time on the transformed image resulting from the previous iteration, consecutively summing over the output of all iterations in order to obtain the desired skeleton maps. After, they have taken into consideration the intersection over union of the precision and sensitivity between the ground-truth and respective skeleton maps.
%After extracting the skeleton maps, the skeleton loss takes into consideration the intersection over union between the precision of the ground-truth maps and predicted skeleton with the sensitivity between the predicted segmentation and ground-truth skeleton.
In our work, we have produced the contour maps by considering the subtraction of the erosion of the original segmentation map from the dilation of the eroded as is shown in \figurename ~\ref{fig:Contour_function}. After, we optimized the mean squared error between the sum of the ground-truth contour map representing ground-truth contour length vs. the predicted contour maps representing predicted contour length. 

\begin{figure}
    \centering
    \includegraphics[width=0.6\textwidth]{img/contour_function_2.pdf}
    \caption{Principle of the contour function $\digamma$: the difference (-) between the erosion (min-pool) and the dilation(max-pool) layers followed by a ReLu layer. Right side: example of ground-truth segmentation image and respective contour image.}
    \label{fig:Contour_function}
\end{figure}

\subsection{Loss Formulation}
Let $\Omega \subset \mathbb{R}^2$ be the spatial image domain. Let  $\mathbf{y}$ be the true label map  and $\mathbf{\widehat{y}} $  the predicted label (probability) map, both of dimension $ |\Omega|$. Consider $\digamma$ to be a function that extracts the contour map of any image, as described in the previous section. The proposed loss is defined as a combination of the Dice loss \cite{V-NET} and the perimeter-based loss weighted by $\lambda$ as follows: 

\begin{equation}
  \mathcal{L} =(1-\lambda) \mathcal{L}_{Dice} + \lambda \mathcal{L}_{perim}
      \label{all-loss}
\end{equation}
with
\begin{equation}
    \mathcal{L}_{perim} =  \left( \sum_{p \in \Omega} \widehat{y_p^F}  - \sum_{p \in \Omega}y_p^F\right)^2
    \label{perimeter-based-loss}
\end{equation}
where $y_p^F$ (resp. $\widehat{y_p^F}$) is the value of  pixel $p$ in the map $\digamma(\mathbf{y})$ (resp.. $\digamma(\widehat{\mathbf{y}})$), equal to $y_p$ (resp.. $\widehat{y_p}$), if $p$ belongs to the contour, 0 otherwise.
%\begin{equation}
%    \mathcal{L}_{perim} = ||\digamma(\mathbf{y}) - \digamma(\widehat{\mathbf{y}})||^2 = (\sum_{p \in \Omega} %\widehat{y_p^F}  - \sum_{p \in \Omega}y_p^F)^2
%    \label{perimeter-based-loss}
%\quad \text{where }\digamma(y)=
%\begin{cases}
%$y_p^F=1$ &  \text{for } p \in \mathcal{C}\\
%$y_p^F=0$ & \text{else}
%\end{cases}
%\end{equation}
%As is indicated in equation \ref{perimeter-based-loss}, 
The contour function $\digamma$ extracts for each of the predicted and ground-truth segmentation maps, a contour map of the segmented objects. The proposed loss then sums over the pixels for both the predicted and ground-truth contour maps and minimizes the mean squared error between them. Hence, one can consider the proposed perimeter-based loss as a regularizing term on the object perimeter. 


\section{Experiments}  \label{expSetting}

\subsection{Datasets}

In order to assess the added value of the proposed perimeter-based loss, several anatomical datasets are considered, with organs presenting varying characteristics in terms of size, shape, and border smoothness. The spleen dataset is a CT dataset from  the Medical Segmentation Decathlon\footnote{\href{http://medicaldecathlon.com/}{http://medicaldecathlon.com/}} whose objective is to segment a single organ (the spleen) characterized with a largely varying size and mild convexity issues at boundary levels, as is shown in \figurename~\ref{Datasets}. The spleen dataset is composed of 41 patients divided into 32 for training and 9 for validation. The Hippocampus Dataset is also a medical Decathlon dataset designed for the segmentation of 2 neighboring tissues in the brain. It is composed of 263 mono-modal MRI scans divided into 206 patients for training and 56 for validation. The ACDC dataset is a cardiac cine MRI dataset consisting of 123 patients divided into 99 training and 24 validation. The task at hand is to segment simultaneously three elements of the heart: the left and right ventricular endocardium (LVC and RVC, resp.) and the myocardium (MYO). The segmentation task is rather challenging as the 3 components are in very close proximity to each other and are characterized by non-convex shapes or holes.
%Thus, the LVC consists of holes that encompass the simple circular shaped MYO and that is in very close proximity to the RVC. On the other hand, the RVC resembles the spleen shape in its extreme curvatures and non-convex nature \figureautorefname~\ref{Datasets}. 


\subsection{Implementation details}
\label{impl}
%\textbf{Training Framework}:
%To ensure the validity of the benchmark, we needed to establish training given a valid experimental setting. For this reason, 
We deploy the unified U-Net based \cite{Unet} framework proposed in \cite{Kervadec2019_BoundaryLoss,KERVADEC2019_SizeLoss, kervadec2020} and modify the loss function accordingly. Training is done using a batch size of 8 and a learning rate of $10^{-3}$.  The learning rate is halved if the
validation performance does not improve during 20 epochs. In the implementation of the contour function $\mathcal{F}$, max and min pooling were carried out via a kernel of size (3,3) and stride of 1. Since the contour extraction function is mainly composed of non-trainable layers, there is no considerable addition to the complexity of the network or the computational cost. Our code is publically available on GitHub \footnote{\href{https://github.com/rosanajurdi/Perimeter_loss}{https://github.com/rosanajurdi/\texttt{Perimeter\_loss}}} 

%\textbf{Training Strategy}:
The U-Net is trained with the loss as defined in Eq. \ref{all-loss}, with a dynamic 
%, we have used the continuous penalty based approach with dynamic
fine-tuning of the parameter $\lambda $ which was conducted in \cite{Kervadec2019_BoundaryLoss}. Thus, the parameter was set to 0.01 and increased by 0.01 per epoch for 200 epochs for the Spleen and ACDC datasets and for 45 epochs for the Hippocampus dataset.
% For the case of multi-label organ segmentation, we have modified slightly the proposed loss so that it focuses on hard-to-segment organs particularly the (LVC). 
% Thus, aside from the $\lambda$ , which is common for all losses, the contour loss was weighted according to 1 ,0.5,0.5 corresponding to the RVC, the MYO and the LVC organs respectively. 

%\textbf{Data Pre-processing and Cross Validation:}

For pre-processing, we have resized the images to a size of 256 $\times$ 256 and normalized them to the range [0, 1]. 
% Deploying the framework presented by \cite{Kervadec2019_BoundaryLoss, KERVADEC2019_SizeLoss}, 
We have kept negative samples for training and validation. Each dataset was split into train and validation based on an 80 \% , 20 \% partition respectively and validated via three Monte-Carlo simulations \cite{Monte_Carlo_2}.

% \subsection{Comparison to other contour-bases losses}
% We have compared the proposed loss $\mathcal{L}_{perim}$ to the Dice loss alone $\mathcal{L}_{Dice}$ and to two state-of-the-art contour-based losses: the Boundary loss $\mathcal{L}_{Boundary}$ \cite{Kervadec2019_BoundaryLoss} and the Hausdorff loss $\mathcal{L}_{HD}$ \cite{karimi_reducing_2019}, each one trained in conjunction with the $\mathcal{L}_{Dice}$ given the same dynamic strategy presented in \cite{Kervadec2019_BoundaryLoss} and explained in section \ref{impl}. Both are based on a distance map.
% Let $D_G(p)$ denote the distance of pixel $p$ to the closest contour ($G$) point. 
% The Boundary loss $\mathcal{L}_{Boundary}$ is an approximation of the distance between the real and the estimated boundaries and is defined as:
% \begin{equation}
% \small
% \mathcal{L}_{Boundary} = \sum_{p \in \Omega} \phi_g(p). \hat{y}_p \qquad \quad 
%   \text{with } \phi_g(p) = 
% \begin{cases}
% -D_G(p) &  \text{for } p \text{ inside the target region } \\
% D_G(p) & \text{else}
% \end{cases}
% \label{kerva_boundary}
% \end{equation}
% with $\widehat{y}_p$ being the predicted value at pixel $p$.
% The Hausdorff loss $\mathcal{L}_{HD}$ is defined as follows:
% % with $y_p$ being the ground-truth at pixel $p$:
% \begin{equation}
%      \mathcal{L}_{HD} = \frac{1}{|\Omega|}. \sum_{p \in \Omega}(y_p - \hat{y}_p)^2.\Big (D_G(y_p)^{2} + D_G(\hat{y}_p)^{2} \Big  )
%      \label{hauss}
% \end{equation}

%\begin{equation}

%We have also compared  to the skeleton loss ($L_{clDice}$) proposed in \cite{clDice2020}.

\section{Results and analysis} \label{results}
The proposed perimeter-based loss is evaluated in two segmentation settings: a single-organ segmentation setting, where we intend to train the network on the spleen dataset and on each of the structures of the heart in the ACDC dataset independently; and a multi-organ segmentation setting where simultaneous segmentation of the anatomical objects of the Hippocampus and ACDC dataset is carried out. We have compared the proposed loss $\mathcal{L}_{perim}$ to the Dice loss alone $\mathcal{L}_{Dice}$ and to two state-of-the-art contour-based losses: the Boundary loss $\mathcal{L}_{Boundary}$ \cite{Kervadec2019_BoundaryLoss} and the Hausdorff loss $\mathcal{L}_{HD}$ \cite{karimi_reducing_2019}, each one trained in conjunction with the $\mathcal{L}_{Dice}$ given the same dynamic strategy presented in \cite{Kervadec2019_BoundaryLoss} and explained in section \ref{impl}.

%where examples of losses registered violations to contour specifications and border shapes whereas the proposed contour loss, despite it's simplicity, was able to capture these specifications and respect the single-connected componenet of the spleen organ.

\begin{table}[t!]
    \caption{Mean ($\pm$ std) Dice index (\%) and Hausdorff distance (mm) on the Spleen and RVC from ACDC dataset}
    \begin{center}
     \scalebox{0.8}{
    \begin{tabular}{l|cc| cc}
    & \multicolumn{2}{c}{\textbf{\textit{Spleen Dataset}} } & \multicolumn{2}{c}{\textbf{\textit{ACDC Dataset (RVC)}}}\\
     Loss  & Dice index & Hausdorff & Dice index & Hausdorff \\ \hline
      $\mathcal{L}_{Dice}$ &  76.80 $\pm$ 7.59  &   1.33 $\pm$ 0.28   & 81.22 $\pm$ 1.05 &  2.47 $\pm$ 0.04 \\
      $\mathcal{L}_{perim}$ & 58.98 \pm 11.42 & 1.89 \pm 0.35 & 29.34 \pm 11.83 & 4.21 \pm 0.49\\  
       $\mathcal{L}_{Dice}$ + $ \mathcal{L}_{Boundary}$  &  80.38 $\pm$  5.46  &  1.34 $\pm$  0.21 & 81.73 $\pm$ 0.81 &   2.35 $\pm$ 0.01 \\
       $\mathcal{L}_{Dice}$  + $\mathcal{L}_{HD}$  &   91.79 $\pm$ 2.67  &  0.92 $\pm$ 0.15   & 81.47 $\pm$ 1.01  & 2.42 $\pm$ 0.05   \\
    %  $\mathcal{L}_{Dice}$ + $\mathcal{L}_{clDice}$  &  87.15 $\pm$ \13.61  &  1.07 $\pm$ 0.53   \\
    %  $\mathcal{L}_{Dice}$ + $\mathcal{L}_{Size}$ & $86.44 $\pm$ 15.86 $ & $ 1.27 $\pm$ 0.57 $\\ 
    \hline
       $\mathcal{L}_{Dice}$ + $\mathcal{L}_{perim}$  & \textbf{95.39} $\pm$ \textbf{1.26} &  \textbf{0.71 }$\pm$ \textbf{0.07}   & \textbf{85.67 }$\pm$ \textbf{0.50}  & \textbf{2.21 }$\pm$ \textbf{0.09} \\ \hline
       \end{tabular}}
    \end{center}
    \label{tab:spleen_rs}
 
\end{table}


\begin{figure}
    \centering
    \includegraphics[width=1\textwidth]{img/qualitative_results_2.jpg}
    \caption{Segmentation results of the proposed loss against the Dice loss baseline and state-of-the-art losses in red with the ground-truth as a region filled with green for spleen and blue for the right ventricle (RVC) segmentation. Each row is a different image.}
    \label{fig:qualitative_results}
\end{figure}

\subsection{Single Organ Segmentation}
Results reported in \tableautorefname~\ref{tab:spleen_rs} relative to spleen segmentation show that the proposed loss outperforms the Dice baseline and the state-of-the-art boundary losses by a large margin. When compared to the best state-of-the-art performance, the proposed perimeter-based loss has registered an increase by about 4\% and a decrease in about 20\% on the Dice index and Hausdorff distance respectively. Since the spleen is an organ characterized by a concave border, we hypothesize that the significant decrease in Hausdorff distance highlights the ability of the proposed loss in accounting for varying curvature and border irregularities. This is illustrated qualitatively in \figurename~\ref{fig:qualitative_results}, where the proposed loss based on the object perimeter length and that is able to capture the specifications of the spleen contour.


%The objective of this experiment is to determine the behavior of the proposed loss given different shaped objects.

% \textbf{Independent segmentation of cardiac structures in ACDC Dataset:} The significance of the proposed loss relative to concave objects and irregular borders is further verified given the single-organ segmentation experiments conducted on the ACDC dataset where each of the structures of the heart, namely the right ventricular endocardium (RVC), the left ventricular endocardium (LVC) and the myocardium (MYO) were segmented through separate and independent training of the network on the proposed losses. 

Given that the RVC has a concave shape, it is similar to the spleen shape in many ways. Hence, we anticipate a similar behavior of the loss performance. Indeed, from \tableautorefname~\ref{tab:spleen_rs}, we gather that the proposed loss outperforms the best boundary state-of-the-art loss by 4\% in Dice index and by more that 6\% (from 2.35 to 2.21) in Hausdorff distances. Conducting further experiments where the other cardiac structures were segmented independently, we observe that the proposed loss maintains state-of-the-art performance when trained to segment organs with simpler shapes with circles (MYO) or holes (LVC). However, the results are not presented here due to the space limit.

% (See appendix \ref{ACDC_ALLIND}).

% \begin{table}[t!]
%  \caption{Dice index and Hausdorff distance (pixels) results for ACDC (\textit{independent}) segmentation. RVC: right ventricular cavity, MYO: myocardium, LVC: left ventricular cavity}
%  \scalebox{0.8}{
%     \begin{center}
%     \begin{tabular}{l|ccc| ccc}
%         & \multicolumn{3}{c}{Dice index} & \multicolumn{3}{c}{Haussdorf Distance}\\
%       Loss  & RVC & MYO & LVC & RVC & MYO & LVC\\ \hline
%       $L_{Dice}$  & $81.22 \pm 1.05$ & $87.82 \pm1.02$ &$91.78 \pm 0.89$ & $2.47 \pm 0.04$ & $2.54 \pm 0.02 $ & $1.92 \pm 0.02$\\
%       $L_{Dice}$ +  $L_{Boundary}$   & $81.73 \pm 0.81$ & $ 86.53 \pm 0.71$ & $91.13 \pm 0.51 $ &  $ 2.35 \pm 0.01$ & $ 2.55 \pm 0.01$& $ 1.93 \pm 0.00$\\
%       $L_{Dice}$ + $L_{HD}$   & $81.47 \pm 1.01 $ & $84.68$ \pm $0.59$ & $89.91$ \pm $0.71$ & $2.42 \pm 0.05$ & $2.61 \pm 0.06$ & $1.97 \pm 0.05$ \\ \hline
%      $L_{Dice}$ + $l_{clDice}$  & 80.61 \pm 1.27 & 86.82 \pm 0.50 & 89.65 \pm 0.81 &  $ 2.50 \pm 0.09$& $ 2.61 \pm 0.01$ & $2.04 \pm 0.03$ \\
%     %  $L_{Dice}$ + $L_{Size}$ & $84.32$ \pm $1.78$ & $86.76$ \pm $0.9$ & $91.40 \pm 0.1$ & $2.24$ \pm $0.09$ & $2.52$ \pm $0.01$ & $1.89$ \pm $0.02$\\\hline
%       $L_{Dice}$ + $L_{Proposed}$  & \textbf{85.67 }\pm \textbf{0.50} & 87.76\pm 0.34 & \textbf{92.00} \pm \textbf{0.53} & $\textbf{2.21 }\pm \textbf{0.09}$ & $2.55 \pm 0.03$ & $1.92 \pm 0.02$ \\
%       \hline
%     \end{tabular}
%     \end{center}}
%   \label{tab:ACDC_indep}  
% \end{table}

\begin{table}[t!]
    \caption{Dice index and Hausdorff distance (pixels) results for ACDC (\textit{simultaneous}) segmentation. RVC: right ventricular cavity, MYO: myocardium, LVC: left ventricular cavity}
    
    \begin{center}
    \scalebox{0.8}{
    \begin{tabular}{l|ccc|ccc}
        & \multicolumn{3}{c}{ Dice index} & \multicolumn{3}{c}{ Hausdorff Distance }\\
      Loss   & RVC & MYO & LVC  & RVC & MYO & LVC\\ \hline
       $\mathcal{L}_{Dice}$ & 80.79 \pm 0.95 & 83.92 \pm 0.13 & 90.26 \pm 0.13 & 2.44 \pm 0.04 & 2.60 \pm 0.01 & 1.95 \pm 0.02 \\
       $\mathcal{L}_{perim}$ & 23.19 \pm 13.38 & 26.53 \pm 9.63 & 9.78 \pm 4.07 & 4.29 \pm 0.17 & 4.59 \pm 0.43 & 4.39 \pm 0.05\\ 
       $\mathcal{L}_{Dice}$ + $ \mathcal{L}_{Boundary}$ & 81.04 \pm 0.87 & 84.16 \pm 0.83 & 89.53 \pm 0.74  & 2.41 \pm 0.05 & 2.57 \pm 0.01 & 1.95 \pm 0.02 \\
       $\mathcal{L}_{Dice}$ + $\mathcal{L}_{HD}$  &  80.54 \pm 1.30 & 83.91 \pm 0.85 & 88.98 \pm 0.90 & 2.33 \pm 0.04 & 2.65 \pm 0.01 & 1.98 \pm 0.01 \\
    % $\mathcal{L}_{Dice}$ + $\mathcal{L}_{clDice}$  & 83.83\pm 1.39 & 83.24 \pm 0.66 & 89.56 \pm 1.10 & 2.34 \pm 0.08 & 2.71 \pm 0.04 & 1.98 \pm 0.04  \\ 
    % $\mathcal{L}_{Dice}$ + $\mathcal{L}_{Size}$ & $41.02 \pm 38.39$  &  $83.41 \pm 0.72$ & $89.74 \pm 0.71$ & $3.88 \pm 1.44$ & $2.62 \pm 0.00$ &  $1.94 \pm 0.01$\\
    
    \hline
       $\mathcal{L}_{Dice}$ + $\mathcal{L}_{perim}$  & \textbf{84.49 }\pm \textbf{0.57 }& \textbf{86.22} \pm \textbf{0.41 }& \textbf{90.69} \pm \textbf{0.41 } &\textbf{ 2.19} \pm \textbf{0.03} & \textbf{2.55} \pm \textbf{0.04} & \textbf{1.94} \pm \textbf{0.02 }\\
      

      \hline
       
    \end{tabular}}
    \end{center}
    \label{tab:ACDC-Sim}
\end{table}








\begin{figure}
    \begin{center}
\includegraphics[width=15cm, height = 4.5cm]{img/evolution_3.pdf}
    \caption{Curve evolution of Dice index on the three cardiac structures of the ACDC dataset in the multi-label segmentation. RVC/LVC: right/left ventricular cavity, MYO: myocardium} 
    \label{fig:evolution}
    \end{center}
\end{figure}
\subsection{Multi-organ segmentation}
% Results on both the Dice index and Hausdorff distance
We have benchmarked the performances of the proposed loss on the Hippocampus dataset, which is composed of two neighboring structures, and on the ACDC datasets with the 3 cardiac structures.
Multi-label segmentation performance on ACDC as shown in \tableautorefname~\ref{tab:ACDC-Sim} reveals that training the model via the perimeter-based loss in conjunction with the Dice loss not only allowed improved segmentation on the irregular shaped RVC but also on the LVC and MYO as well. This shows that improving segmentation performance on the hard-to-segment LVC has permitted proper delineation of other organs in its neighborhood. These observations were further validated by the evolution plot of the Dice index of its 3 structures as shown in \figurename~\ref{fig:evolution} given the 3 state-of-the-art losses against our proposed loss.
%To validate the role of the proposed loss in the multi-organ segmentation setting, We have benchmarked the performances on the hippocampus dataset , which is composed of two neighboring structures.
Regarding the Hippocampus dataset, \tableautorefname~\ref{tab:Hippo_results} shows that the proposed loss improves the Dice index and Hausdorff distance, for both tissues, by a considerable margin when compared relative to the state-of-the-art boundary losses. This verifies the ability of the proposed loss to properly delineate neighboring structures relative to other contour-based losses in the domain.

\begin{table}[]
 \caption{Results for the Hippocampus Dataset. H1: green tissue, H2: pink tissue}

    \begin{center}
     \scalebox{0.8}{
    \begin{tabular}{l|cc|cc}
        & \multicolumn{2}{c}{Dice index} & \multicolumn{2}{c}{Hausdorff Distance}\\
      Loss  & H1 & H2  & H1 & H2 \\ \hline
       $\mathcal{L}_{Dice}$  & 49.37 $\pm$ 1.76 & 66.85 $\pm$ 3.73 & 3.89 $\pm$ 0.14 & 2.52 $\pm$ 0.18\\
       $\mathcal{L}_{perim}$ & $16.60 \pm	10.06$ & $36.21 \pm	1.68$ & $7.97 \pm 6.33$ & $3.10 \pm 0.12$ \\
       $\mathcal{L}_{Dice}$ + $ \mathcal{L}_{Boundary}$ & 62.86 $\pm$ 0.59  & 75.52 $\pm$ 0.48 & 3.18 $\pm$ 0.02 & 2.16 $\pm$ 0.02\\
       $\mathcal{L}_{Dice}$ + $\mathcal{L}_{HD}$ & 62.46 $\pm$ 3.34 & 74.12 $\pm$ 3.42 & 3.16 $\pm$ 0.04 & 2.44 $\pm$ 0.25\\
        % $\mathcal{L}_{Dice}$ +$\mathcal{L}_{clDice}$ & \textbf{69.81} $\pm$\textbf{ 0.09} & \textbf{83.41 }$\pm$ \textbf{0.20} & \textbf{3.10 }$\pm$ \textbf{0.01} & \textbf{1.94 }$\pm$\textbf{ 0.00 } \\ 
       \hline  
       $\mathcal{L}_{Dice}$ +$\mathcal{L}_{perim}$ & \textbf{67.52} $\pm$\textbf{ 0.21} & \textbf{79.80 }$\pm$\textbf{ 0.46} & \textbf{3.07} $\pm$ \textbf{0.03} & \textbf{2.01 }$\pm$ \textbf{0.00}\\
      \hline
    \end{tabular}}
    \end{center}
  \label{tab:Hippo_results}  
\end{table}

%  $\mathcal{L}_{Dice}$ \\
%   $\mathcal{L}_{Dice}$ +$\mathcal{L}_{perim}$ \\
%   $\mathcal{L}_{Dice}$ +$\mathcal{L}_{HD}$ \\
%     $\mathcal{L}_{Dice}$ +$\mathcal{L}_{Boundary}$ \\

\section{Conclusion} \label{conclusion} 

In this work, we propose a novel contour-based loss for medical image segmentation. The proposed loss considers the perimeter length of the segmented organ instead of exact boundary matching as is usually done in present state-of-the-art boundary losses in the field.
%In this work, we propose a novel perimeter-based loss that tackles the medical image segmentation in a more efficient and less  computationally expensive manner, relative to present state-of-the-art boundary losses in the field. 
% We take advantage of the network architecture to compute a morphological gradient of both the ground-truth and the probability map.  
We evaluate the proposed loss against three different datasets, which are characterized by varying and non-convex shapes. Despite the simplicity of the proposed loss, it is able to exceed state-of-the-art boundary loss performances by a large margin for both single and multi-organ segmentation. Future work includes customizing the proposed loss to accommodate multi-connected component organs and investigating different weighting strategies for the multi-organ segmentation setting under the proposed loss based on the degree of border irregularity of the considered organs.
% Future work includes customizing the proposed loss to multi-connected component organs and extension to 3D segmentation in the form of a loss that takes into consideration the surface occupied by a particular organ.

\midlacknowledgments{The authors would like to acknowledge the 
CNRS-Lebanon and
AUF for granting a doctoral fellowship to R. El Jurdi, as well as the ANR (Project APi, grant ANR-18-CE23-0014) and the CRIANN  
for providing computational resources. This work is part of the DAISI project, co-financed by the European Union with the European Regional Development Fund (ERDF) and by the Normandy Region, and the WeSmile project funded by PHC VanGogh.}

\bibliographystyle{ieeetr}
\bibliography{ELJURDI21}

% \appendix

% \section{Tabulating state-of-the-art losses relative to the proposed loss}

% % \begin{equation}
% % \small
% % L_{Boundary} = \sum_{p \in \Omega} \phi_g(p). \hat{y_p} \qquad \quad 
% %   \phi_g(p) = 
% % \begin{cases}
% % -D_g(p) &  p \in \mathcal{C}\\
% % D_g(p) & Else
% % \end{cases}
% % \label{kerva_boundary}
% % \end{equation}

% % \begin{equation}
% %      L_{HD} = \frac{1}{|\Omega|}. \sum_{p \in \Omega}(y_p - \hat{y_p})^2.\Big (D_g(y_p)^{2} + D_g(\hat{y_p })^{2} \Big  )
% %      \label{hauss}
% % \end{equation}


% In this section, we compare state-of-the-art loss equations relative to the proposed loss.
% \begin{table}[h!]
%     \caption{ }
%     \begin{center}
%     \begin{tabular}{l|ccc}
%       Loss   & Equation \\ \hline
%       $\mathcal{L}_{Boundary}$ \cite{Kervadec2019_BoundaryLoss} & $$
%     \mathcal{L}_{Boundary} = \sum_{q \in \Omega} \phi_g(q). p(y_q)
    
% $$

%  \\ \hline
      
% Hausdorff \cite{karimi_reducing_2019} & $$
%     \mathcal{L}_{HD}(q,p) = \frac{1}{|\Omega|}. \sum_{\Omega}(p - q)^2.(d_p^{\alpha} - d_q^{\alpha})
   
% $$

% \\ \hline
   
%       Boundary Enhanced \cite{Yang2018}&  \mathcal{L}_{BE} = || \mathcal{L}(\hat{y_p}) - \mathcal{L}(y_p)||_2  \\
%       \hline
%       Boundary Loss 2 \cite{caliva2019_MIDL} & $$
%     \mathcal{L}_{Dist-Penalty} = \frac{1}{N}. \sum_{i = 1} (1+ D_G) \circ \sum_{r = 1}{K} -y_p^r.log(\hat{y_p^r}) 
 
% $$ \\ \hline

% Shape-aware Loss \cite{Arif2018}&   $$\mathcal{L}_{shape} = - \sum_{p \in \hat{\Omega}_p}\sum_{r =1}^{K}y_{p}^r.E_i.log(P(y_p^r|x_p; w))
% $$
%  \\\hline
%  Proposed loss & \begin{equation}
%     \mathcal{L}_{SC} = ||\digamma(y) - \digamma(\widehat{y})||^2 = (\sum_{\widehat{y_p^F} \in \digamma(y)}\widehat{y_p^F}  - \sum_{y_p^F \in \digamma(y)}y_p^F)^2
%     \label{hhh}
% \end{equation}\\ \hline
       
%     \end{tabular}
%     \end{center}
%     \label{tab:Multi-HS}
% \end{table}

%\section{Results on ACDC Independent } \label{ACDC_ALLIND}


\end{document}
