## 2 Materials and Methods
### BiomedCLIP Methodology
Each X-ray image was preprocessed through normalization before being input into the model. The model then computed the probability of the image belonging to each scoliosis category, with a confidence score ranging from 0 to 1. This score was used as a quantitative measure of the model's certainty in its predictions. The evaluation emphasized accuracy in image classification and the ability to generalize across unseen medical image data, testing both the robustness and real-world applicability of Biomed CLIP in clinical diagnostics. Detection and Classification Framework  
**Detection and Classification Methodology**  
**Detection of Scoliosis**  
The detection process focused on identifying the presence of spinal deformities in posturographic X-ray images. The BiomedCLIP model was utilized to automatically determine whether a given image depicted scoliosis. The steps involved in detection included:  
* **Approach**: Detection was conducted using descriptive text labels, assigning each image to one of two categories: \"This is an image of scoliosis\" or \"This is not an image of scoliosis\". * The model's vision encoder, based on the ViT-B/16 architecture, divided the input images into 16 \(\times\) 16-pixel patches for analysis. * Images were normalized and resized to 224 \(\times\) 224 pixels prior to being fed into the model. * The text encoder was extended to handle up to 256 tokens, accommodating detailed biomedical descriptions. * **Outcome**: The model computed the probability of the image belonging to the category of scoliosis, with confidence scores ranging from 0 to 1, providing a quantitative measure of detection. **Classification of Scoliosis**  
Once scoliosis was detected, the images were further classified into two additional dimensions: the type of scoliosis (single-curve or double-curve) and the severity of the condition (mild, moderate, or severe). * **Classification of Scoliosis Type:**
* **Approach**: Images were categorized based on their curvature type:
* \"This is an image of single-curve scoliosis\". * \"This is an image of double-curve scoliosis\". * The same preprocessing steps as in the detection process were applied, with images resized to 224 \(\times\) 224 pixels and normalized. * Textual prompts tailored to the classification task were used to improve model specificity. * **Outcome**: The model assigned probabilities to each category, identifying the type of scoliosis with high confidence. * **Classification of Scoliosis Severity:**
* **Approach**: Severity classification divided images into three categories:* Mild scoliosis (\"This is an image of mild scoliosis\"). * Moderate scoliosis (\"This is an image of moderate scoliosis\"). * Severe scoliosis (\"This is an image of severe scoliosis\"). * **Parameters:**
* Severity levels were defined based on the Cobb angle measurements:
* Mild: \(\lnot\)20\({}^{\circ}\). * Moderate: 20\({}^{\circ}\)-40\({}^{\circ}\). * Severe: \(\lnot\)40\({}^{\circ}\). * The model's vision encoder leveraged detailed geometric features of the X-ray images to differentiate between severity levels. * **Outcome**: Probabilities were calculated for each severity category, enabling precise classification of the scoliosis stage. **Integration of Detection and Classification**  
Both detection and classification were performed using the BiomedCLIP model, fine-tuned to handle pediatric spinal imagery. Although these processes shared a common model architecture, they were treated as distinct stages in the analysis pipeline. The detection stage established the presence of scoliosis, while the classification stages refined the analysis by identifying the specific type and severity. By addressing detection and classification as separate processes, this methodology ensured a clear, structured workflow and optimized the model's performance for each task. The parameters and technical solutions implemented for both stages are detailed in the corresponding sections of the methodology.