# Adapting the Segment Anything Model for Volumetric X-ray Data-Sets of Arbitrary Sizes
## 2 Materials and Methods
### Inference Workflow for Volumetric Data-Sets
#### 2.3.1 Adapting SAM for Volumetric Data-Sets  
Adapting SAM, which was originally designed for segmenting image data-sets, to our volumetric CT data-sets required certain modifications and the implementation of appropriate post-processing steps. In this section, we explore various possibilities for this transition and subsequently outline the approach we finally selected. Several 2D to 3D techniques can be utilized to facilitate this transformation [26]. For example, in [27], a Volumetric Fusion Net (VFN) was employed to merge multiple 2D segmentation predictions into a comprehensive 3D prediction volume. In a related work, Ref. [28] adopted a similar methodology for pancreas segmentation, albeit utilizing a different VFN. According to [26], other approaches involve incorporating neighbouring 2D slices as additional channel information or utilizing specialized topologies to extract and merge features in both the 2D and 3D domains. However, the effectiveness of these \begin{table}
\begin{tabular}{p{113.8 pt} p{113.8 pt} p{113.8 pt}} \hline \hline
**Stage** & **Algorithm** & **Description (_Options_)** \\ \hline
**Preprocess Slice Algorithms** & & \\  & Slice Normalization & Normalization of pixel values in each slice to the minimum and maximum range of the slice. & \\  & Outlier and Empty Slice Detection & Identification and handling of outlier and empty slices. & \\  & RGB Conversion & Conversion of grey values to RGB colour in order to comply with SAM interface requirements. & \\  & Enframing & Adds a zero-padded border to each slice to centre the seed point to comply with SAM interface requirements. & \\  & Estimated Foreground Volume & Utilizes different _binarization strategies_ and _thresholds_ to estimate the foreground volume. & \\ \hline
**Predict Slice Algorithms** & & \\  & Prompt Type & Type of prompt is used for invoking SAM: point prompt for tile centre and dense prompt from accumulator. & \\  & Multimask Output Selector & Select mask from multiple disambiguating instance output channels predicted by SAM: maximum predicted IoU, fixed index of channel; maximum IoU with estimated foreground to avoid segmenting background; and minimum count of voxels to reduce under segmentation. & \\  & Mask Output Selector & Selected output format of SAM: binary full resolution mask and quarter resolution logits with subsequent _threshold_ and _upscaling algorithm_. & \\ \hline
**Postprocess Slice Algorithms** & & \\  & Seed Point Filter & Aborts or continues prediction based on the seed point’s classification as background or foreground (_count of slices_). & \\  & Merge Slice Rule & Rule that should be used to decide if and how to merge slices to stacks and when to abort an computation stack: _Always_; _BreakOnEmptySlicz_; _MinimumIOUTloLastSlice_ (_threshold_); _MinimumIOUTloForeground_ (_threshold_). & \\  & Slice Median & Apply median filter to each slice (_enabled or disabled_). & \\  & Connected Component Analysis and analyse connected components and keep only segment connected to seed point (_enabled or disabled_). & \\ \hline
**Postprocess Volume Algorithms** & & \\  & Merge Slice Predictions & Merge orthogonal slice stack predictions based on _count_ of foreground voxels. & \\  & Volume Median & Apply median filter to merged volume (_enabled or disabled_). & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Overview of algorithm choices and options for different stages of the volumetric SAM adaption seen in Figure 6.  
methods for improving segmentation results heavily depends on the specific data-sets at hand. Due to reports on the segmentation performance of SAM on volumetric medical data-sets, such as those in [29] and our own preliminary experiments, which suggested that the segmentation quality of SAM was likely to be mixed, we opted for a simple majority voting approach to merge the 2D predictions into 3D volumes. During the slice merging process, we experimented with different rules to determine when to terminate the slice-wise merging.