<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Liohtml</title>
    <description>The latest articles on DEV Community by Liohtml (@liohtml).</description>
    <link>https://dev.to/liohtml</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3944049%2Fe18dc66f-50aa-4715-b419-2b5ba5b81054.png</url>
      <title>DEV Community: Liohtml</title>
      <link>https://dev.to/liohtml</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/liohtml"/>
    <language>en</language>
    <item>
      <title>How I Reverse-Engineered a Radiology Portal and Built an Open-Source MRI Analyzer</title>
      <dc:creator>Liohtml</dc:creator>
      <pubDate>Thu, 21 May 2026 12:15:39 +0000</pubDate>
      <link>https://dev.to/liohtml/how-i-reverse-engineered-a-radiology-portal-and-built-an-open-source-mri-analyzer-2lh3</link>
      <guid>https://dev.to/liohtml/how-i-reverse-engineered-a-radiology-portal-and-built-an-open-source-mri-analyzer-2lh3</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Two weeks ago, I got a knee MRI after a Brazilian Jiu-Jitsu injury (a "knee reaping" - massive valgus stress + external rotation). My doctor sent me a link to view my images on an &lt;strong&gt;easyRadiology&lt;/strong&gt; portal.&lt;/p&gt;

&lt;p&gt;I clicked the link. Login screen. Entered my code. The viewer loaded. My knee MRI appeared on screen.&lt;/p&gt;

&lt;p&gt;But here's the thing - I wanted to &lt;strong&gt;download&lt;/strong&gt; my own images and analyze them. The portal had a download button, but the files were completely encrypted. I couldn't open them in any DICOM viewer.&lt;/p&gt;

&lt;p&gt;So I did what any engineer would do: I opened DevTools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reverse-Engineering the Encryption
&lt;/h2&gt;

&lt;p&gt;The portal uses a multi-layer encryption scheme:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Access code&lt;/strong&gt; (&lt;code&gt;K6P-8ZT-M9X-9JE&lt;/code&gt;) is split into a &lt;code&gt;ViewCodeName&lt;/code&gt; and a password&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;scrypt key verification&lt;/strong&gt; proves you know the password without sending it&lt;/li&gt;
&lt;li&gt;The server returns an &lt;strong&gt;encrypted access key&lt;/strong&gt; (AES-CBC with scrypt-derived key)&lt;/li&gt;
&lt;li&gt;This access key decrypts the &lt;strong&gt;patient data JSON&lt;/strong&gt; (which contains yet another password)&lt;/li&gt;
&lt;li&gt;That final password decrypts the actual &lt;strong&gt;DICOM image data&lt;/strong&gt; (AES-256, WinZip format)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access Code -&amp;gt; scrypt -&amp;gt; KeyVerification -&amp;gt; API -&amp;gt; Encrypted AccessKey
                                                        |
                                                   scrypt + AES-CBC
                                                        |
                                                   AccessKey (plain)
                                                        |
                                            Decrypt PatientData JSON
                                                        |
                                            PasswordForDicomZip
                                                        |
                                            AES-256 decrypt DICOM entries
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I traced every network request in Playwright, read the minified JavaScript, and implemented the full decryption chain in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Derive key using scrypt (matching the portal's JS implementation)
&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;16384&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dklen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Decrypt with AES-CBC
&lt;/span&gt;&lt;span class="n"&gt;cipher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MODE_CBC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;iv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;decrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cipher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ciphertext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Result: {"PasswordForDicomZip": "rqNRwRnB-aU6H4fM3-..."}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;140 DICOM files decrypted.&lt;/strong&gt; My knee images, finally accessible.&lt;/p&gt;

&lt;h2&gt;
  
  
  From Decryption to AI Analysis
&lt;/h2&gt;

&lt;p&gt;With the images in hand, I thought: &lt;em&gt;what if I could analyze them automatically?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Local ML Analysis
&lt;/h3&gt;

&lt;p&gt;I used a pretrained &lt;strong&gt;ResNet18&lt;/strong&gt; (ImageNet weights) as a feature extractor. For each MRI slice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extract a 512-dimensional feature vector&lt;/li&gt;
&lt;li&gt;Compute anomaly scores (distance from series mean)&lt;/li&gt;
&lt;li&gt;Analyze signal intensity patterns (high signal on PD FS = fluid/edema)&lt;/li&gt;
&lt;li&gt;Identify the top suspicious slices
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Feature extraction per slice
&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;resnet18_features&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# (28, 512)
&lt;/span&gt;&lt;span class="n"&gt;anomaly_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;normalized_distance_from_mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;features&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# (28,)
&lt;/span&gt;&lt;span class="n"&gt;top_slices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;argsort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;anomaly_scores&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;  &lt;span class="c1"&gt;# Most suspicious
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Vision-LLM Analysis
&lt;/h3&gt;

&lt;p&gt;Then I fed the key slices to &lt;strong&gt;Claude Opus 4.7&lt;/strong&gt; with a structured medical prompt including my clinical context:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Knee Reaping in BJJ 10 days ago. Valgus stress + external rotation. Audible pop. Point tenderness at tibial MCL insertion."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude analyzed each structure systematically - ACL, MCL, meniscus, bone bruise, cartilage, effusion - and returned structured JSON findings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; MCL Grade I-II at the tibial insertion (matching my point tenderness exactly), intact ACL, no bone bruise, mild effusion. The clinical correlation noted that the "pop" was unusual for an isolated MCL injury.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Professional PDF Report
&lt;/h3&gt;

&lt;p&gt;I generated a 6-page PDF with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Annotated MRI images (arrows, circles, color-coded findings)&lt;/li&gt;
&lt;li&gt;Per-structure findings tables&lt;/li&gt;
&lt;li&gt;Traffic-light summary (normal/borderline/pathological)&lt;/li&gt;
&lt;li&gt;Clinical correlation and recommendations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Making It Open-Source: MedCheck
&lt;/h2&gt;

&lt;p&gt;I realized this could help others. So I packaged everything into &lt;strong&gt;MedCheck&lt;/strong&gt; - an open-source toolkit that anyone can use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ingest -&amp;gt; Preprocess -&amp;gt; ML Analysis -&amp;gt; Vision AI -&amp;gt; Report
  |           |             |              |           |
  v           v             v              v           v
DICOM      Normalize    ResNet18      Claude/GPT    PDF/HTML
Portal     Detect       Anomaly       GPT-5.5      Annotated
Local      anatomy      scores        Gemini       images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multiple data sources&lt;/strong&gt;: Local DICOM files, ZIP archives, or fetch directly from radiology portals&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local ML&lt;/strong&gt;: ResNet18 anomaly detection - no API key needed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vision-LLMs&lt;/strong&gt;: Claude Opus 4.7, GPT-5.5, Gemini 3.5 Flash with automatic fallback&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clinical context&lt;/strong&gt;: Input your symptoms and trauma history for targeted analysis&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Professional reports&lt;/strong&gt;: PDF with annotated images, HTML for interactive viewing, JSON for APIs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker-ready&lt;/strong&gt;: &lt;code&gt;docker run&lt;/code&gt; and open your browser&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;YAML workflows&lt;/strong&gt;: Define custom analysis pipelines&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quick Start
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;medcheck

&lt;span class="c"&gt;# Analyze local DICOM files&lt;/span&gt;
medcheck analyze ./my-dicom-folder &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--symptoms&lt;/span&gt; &lt;span class="s2"&gt;"Medial knee pain"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--trauma&lt;/span&gt; &lt;span class="s2"&gt;"Valgus stress injury"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--model&lt;/span&gt; claude &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--report&lt;/span&gt; pdf

&lt;span class="c"&gt;# Or use Docker&lt;/span&gt;
docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sk-... &lt;span class="se"&gt;\&lt;/span&gt;
  ghcr.io/liohtml/medcheck:lite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Supported Anatomy
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Region&lt;/th&gt;
&lt;th&gt;Structures Analyzed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Knee&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;ACL, PCL, MCL, LCL, menisci, cartilage, bone bruise, effusion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Shoulder&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Rotator cuff, labrum, biceps tendon, AC joint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Spine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Discs, stenosis, foramina, vertebral bodies, ligaments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;More coming&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Hip (#10), Ankle (#11), Wrist (#12)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Want to Contribute?
&lt;/h2&gt;

&lt;p&gt;MedCheck has &lt;strong&gt;9 open issues&lt;/strong&gt; labeled &lt;code&gt;good first issue&lt;/code&gt; - perfect for first-time contributors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Add anatomy templates&lt;/strong&gt; (hip, ankle, wrist) - if you know anatomy, you can help&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New data providers&lt;/strong&gt; (Orthanc, DICOMweb) - if you work with DICOM servers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Translations&lt;/strong&gt; (French, Spanish) - if you speak these languages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test coverage&lt;/strong&gt; - always welcome&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local LLM&lt;/strong&gt; (LLaVA-Med) - for fully offline analysis
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Get started in 30 seconds&lt;/span&gt;
git clone https://github.com/Liohtml/MedCheck.git
&lt;span class="nb"&gt;cd &lt;/span&gt;MedCheck
uv &lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="nt"&gt;--all-extras&lt;/span&gt;
uv run pytest  &lt;span class="c"&gt;# 65 tests, all passing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Important Disclaimer
&lt;/h2&gt;

&lt;p&gt;MedCheck is &lt;strong&gt;NOT a medical device&lt;/strong&gt;. It's a research and educational tool. All analysis results must be verified by a qualified radiologist. Don't make medical decisions based solely on MedCheck output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/Liohtml/MedCheck" rel="noopener noreferrer"&gt;github.com/Liohtml/MedCheck&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PyPI&lt;/strong&gt;: &lt;a href="https://pypi.org/project/medcheck/" rel="noopener noreferrer"&gt;pypi.org/project/medcheck&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discussion&lt;/strong&gt;: &lt;a href="https://github.com/Liohtml/MedCheck/discussions/19" rel="noopener noreferrer"&gt;GitHub Discussions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Have you worked with medical imaging or DICOM data? I'd love to hear about your experiences in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>opensource</category>
      <category>machinelearning</category>
      <category>healthcare</category>
    </item>
  </channel>
</rss>
