Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Backend CI

on:
push:
paths:
- "apps/backend/**"
- "package/**"
pull_request:
paths:
- "apps/backend/**"
- "package/**"

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
cd apps/backend
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-regressions httpx

- name: Install package (editable)
run: |
cd package
pip install -e .

- name: Run tests
run: |
cd apps/backend
pytest -v
24 changes: 24 additions & 0 deletions apps/backend/tests/test_api_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from fastapi.testclient import TestClient
from app.main import app

client = TestClient(app)


def test_bids_endpoint_returns_expected_schema():
response = client.post(
"/api/report/process/bids",
data={"modality": "ASL"}
)

assert response.status_code == 200
data = response.json()

expected_keys = {
"basic_report",
"extended_report",
"asl_parameters",
"errors",
"warnings",
}

assert expected_keys.issubset(data.keys())
46 changes: 46 additions & 0 deletions apps/backend/tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from fastapi.testclient import TestClient
from app.main import app

client = TestClient(app)


def normalize_response(data: dict) -> dict:
"""
Remove volatile fields to ensure deterministic regression.
"""
data.pop("nifti_slice_number", None)
return data


def test_root_endpoint_regression(data_regression):
response = client.get("/")
assert response.status_code == 200

data = response.json()
data_regression.check(data)


def test_bids_endpoint_regression(data_regression):
response = client.post(
"/api/report/process/bids",
data={"modality": "ASL"}
)

assert response.status_code == 200

data = normalize_response(response.json())
data_regression.check(data)


def test_dicom_invalid_file_returns_500(tmp_path):
file_path = tmp_path / "invalid.txt"
file_path.write_text("not a dicom")

with open(file_path, "rb") as f:
response = client.post(
"/api/report/process/dicom", # fixed /api prefix
files={"dcm_files": ("invalid.txt", f, "text/plain")},
data={"modality": "ASL"},
)

assert response.status_code == 500
2 changes: 1 addition & 1 deletion apps/frontend/src/app/_home/UploadButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const UploadButtons = () => {
)}
onClick={() => setActiveFileTypeOption(UploadDataType.BIDS)}
>
BDIS
BIDS
</Button>
<Button
type="button"
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/app/_home/WhatIsThisTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const WhatIsThisTool = () => {
<p className="mt-3">
Here are some sample folders for you to download and test:
</p>
<Button className="w-fit hover:cursor-pointer" aria-label="Download sample BDIS data">
<Button className="w-fit hover:cursor-pointer" aria-label="Download sample BIDS data">
<Link href="https://drive.google.com/drive/folders/1NuG_ofLbaLYswNlBN2aRDkxLOucYFQfg"
target="_blank" rel="noopener noreferrer">
Sample ASL BDIS data
Sample ASL BIDS data
</Link>
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/app/_layout/navigation-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const NavData: {
countType: "warnings",
},
{
title: "Convert DICOM to BDIS",
url: "/convert/dcm-to-bdis",
title: "Convert DICOM to BIDS",
url: "/convert/dcm-to-bids",
icon: IconTransform,
showCount: false,
}
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/app/convert/dcm-to-bdis/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const Page = () => {
return (
<div className="flex flex-col items-center justify-center h-full">
<h1 className="text-2xl font-bold mb-4">DCM to BDIS Conversion</h1>
<h1 className="text-2xl font-bold mb-4">DCM to BIDS Conversion</h1>
<p className="text-gray-600">This feature is under development.</p>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/Package-Arch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/development/architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ modalities/

#### Sequence Management

This Handles the extraction of BDIS metadata (e.g. asl.json) from DICOM for vendors and organization implementation of modalities
This Handles the extraction of BIDS metadata (e.g. asl.json) from DICOM for vendors and organization implementation of modalities

```
sequences/
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ If you have DICOM files:
- Or drag and drop files directly

2. **Select Data Type**:
- Choose "BDIS" for BIDS format
- Choose "BIDS" for BIDS format
- Choose "DICOM" for DICOM files

3. **Select Modality**:
Expand Down