Skip to main content
. 2026 Aug 31;16(17):2805. doi: 10.3390/diagnostics16172805
Algorithm 1 for Lung Cancer Classification Model
Input: CT volume V∈RS×H×W, bounding boxes Bs}s=1S
Output: Predicted histological subtype y^
1. CT Volume Preprocessing
1.1 Intensity clipping: For each slice s=1…S, perform lung window intensity clipping: Ips(x,y)←min(τmax,max(τmin,Is(x,y)))
1.2 Normalization:  Normalize clipped slice for model compatibility: Is′(x,y)←Ips(x,y)−min(Ips)max(Ips)−min(Ips)
1.3 RGB conversion: Convert normalized single-channel slice to RGB: Isrgb(x,y)←[Is′(x,y),Is′(x,y),Is′(x,y)]
Representation:  V←{Isrgb}s=1S∈RS×H×W×3
2. Tumor Region Segmentation using MedSAM
2.1 Bounding box extraction:  Extract bounding box for slice s: Bs←(xmin,ymin,xmax,ymax)
2.2 MedSAM mask generation:  Forward slice and bounding box to MedSAM to generate mask: Ms←fMedSAM(Isrgb,Bs),Ms∈{0,1}H×W
2.3 Mask merging: If multiple regions exist, merge masks pixel-wise: Ms(x,y)←maxkMs,k(x,y)
2.4 Tumor slice selection: Retain tumor slices: T←{s∣∑x,yMs(x,y)>0}
3. Multi-Level Feature Extraction
3.1 Structural and Geometric Features
3.1.1 ORB keypoints: Detect ORB keypoints:
KsORB←{(x,y)∣Ip−Ii>ϵ or Ii−Ip>ϵ, i∈{1,…,16}}
Compute orientation using intensity centroid moments:
θ←tan−1m01m10
Generate rotation-invariant BRIEF descriptors:
τ(p;x,y)←1if p(x)<p(y)0otherwise
3.1.2 Harris corners:  Compute Harris corner response: R(x,y)←det(H)−k⋅(trace(H))2, extract corners: KsH←{(x,y)∣R(x,y)>δ}
3.1.3 Shape descriptors: Compute spatial moments of mask Ms: mpq←∑x∑yxpyqMs(x,y),(x¯,y¯)=(m10/m00,m01/m00)
Central and normalized moments: μpq←∑x∑y(x−x¯)p(y−y¯)qMs(x,y),ηpq←μpqμ001+(p+q)/2
Hu invariants: Hi′←−sign(Hi)log(∣Hi∣),i=1..7
Structural vector: fstructures←[fHu∥KsORB∥KsH]
3.2 Texture Features
3.2.1 Quantization: Quantize intensities: Qs(x,y)←quantize(Is′)
3.2.2 GLCM computation: Compute GLCM P(i,j) and derive: Contrast,Homogeneity,Energy,Correlation,Dissimilarity
3.2.3 LBP computation: Compute LBP: LBP(p)←∑n=0P−1s(gn−gc)2n,s(x)=1 if x≥0,0 otherwise
3.2.4 Texture vector: ftextures←[fGLCM∥fLBP]∈Rdt
3.3 Deep Semantic Features
3.3.1 ROI extraction: Extract tumor ROI: Isroi←Isrgb⊙Ms
3.3.2 ResNet-50 feature extraction: Forward through ResNet-50, global average pooling: fdeeps∈R2048,fdeeps←GAP(F(Isroi))
4. Hybrid Feature Fusion
4.1 Handcrafted fusion: fhands←[fstructures∥ftextures]
4.2 Hybrid fusion: fhybrids←[fhands∥fdeeps](dimension d)
5. Optimal Feature Selection using PSO
5.1 Particle initialization: Initialize particle population pi∈{0,1}d
5.2 Velocity and position update: vi←wvi+c1r1(pbesti−xi)+c2r2(gbest−xi),xi←xi+vi
5.3 Fitness evaluation and selection: F←α⋅Acc−βNsNf,fopts←select(fhybrids)
6. Sequential Modeling and Classification
6.1 Feature sequence construction: F←{fopt1,…,foptT}
6.2 LSTM forward: ht,Ct←LSTMCell(xt,ht−1,Ct−1)
6.3 Final representation: hT
6.4 Logits and SoftMax: z←WhT+b,y^i←ezi∑jezj
Return: Predicted histological subtype y^