-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from NPACore/shim_and_station
Shim and station
- Loading branch information
Showing
48 changed files
with
828 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from template_checker import TemplateChecker, CheckResult | ||
from jinja2 import Template | ||
|
||
def load_template(template_path: str) -> Template: | ||
""" | ||
Load an HTML template from the template.html file | ||
:param template_path: Path to the HTML template file. | ||
:returns: A Jinja2 Template object. | ||
""" | ||
with open(template_path, 'r') as file: | ||
template_content = file.read() | ||
return Template(template_content) | ||
|
||
def generate_html_report(check_result: CheckResult, template_path: str) -> str: | ||
""" | ||
Generate an HTML report of DICOM header comparison, highlighting mismatches. | ||
:param check_result: Output from the check_header function, containing the comparison results. | ||
:returns: HTML string with results formatted using a Jinja2 template. | ||
""" | ||
|
||
# Headers to check | ||
headers_to_check = ["Project", "SequenceName", "TR", "TE", "FA", "iPAT", "Comments"] | ||
|
||
# Initialize the rows list | ||
rows = [] | ||
|
||
# Add rows for each header parameter | ||
for header in headers_to_check: | ||
expected_value = check_result["template"].get(header, "N/A") | ||
actual_value = check_result["input"].get(header, "N/A") | ||
class_name = "mismatch" if header in check_result["errors"] else "match" | ||
rows.append({ | ||
"header": header, | ||
"expected_value": expected_value, | ||
"actual_value": actual_value, | ||
"class_name": class_name | ||
}) | ||
|
||
# Load the template from the file | ||
template = load_template(template_path) | ||
|
||
# Render the template with the data | ||
html = template.render(rows=rows) | ||
|
||
return html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/bash | ||
#Copy the first two DICOM files from rest, task, and dwi folders | ||
# | ||
output_dir="$HOME/src/mrrc-hdr-qa/dicoms/" | ||
|
||
mkdir -p "$output_dir" | ||
|
||
copy_first_two() { | ||
local sessions=("$@") | ||
for session in "${sessions[@]}"; do | ||
# copy the first two dicoms in the session | ||
files=($(ls "$session" | head -n2)) | ||
for file in "${files[@]}"; do | ||
cp "$session/$file" "$output_dir/$(basename "$file")" | ||
done | ||
done | ||
} | ||
|
||
rest_sessions=($(printf "%s\n" /Volumes/Hera/Raw/MRprojects/Habit/2*/1*/Resting-state_ME_4*/ | head -n2)) | ||
task_sessions=($(printf "%s\n" /Volumes/Hera/Raw/MRprojects/Habit/2*/1*/HabitTask_704*/ | head -n2)) | ||
dwi_sessions=($(printf "%s\n" /Volumes/Hera/Raw/MRprojects/Habit/2*/1*/dMRI_b0_AP_1*/ | head -n2)) | ||
|
||
copy_first_two "${rest_sessions[@]}" | ||
copy_first_two "${task_sessions[@]}" | ||
copy_first_two "${dwi_sessions[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
<html> | ||
<head> | ||
<style> | ||
table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
th, td { | ||
border: 1px solid black; | ||
padding: 8px; | ||
text-align: center; | ||
} | ||
th { | ||
background-color: #f2f2f2; | ||
} | ||
.match { background-color: #d4edda; } /* green for matches */ | ||
.mismatch { background-color: #f8d7da; } /* red for mismatches */ | ||
</style> | ||
</head> | ||
<body> | ||
<h2>DICOM Header Compliance Report</h2> | ||
<table> | ||
<tr> | ||
<th>Header</th> | ||
<th>Expected Value</th> | ||
<th>Actual Value</th> | ||
</tr> | ||
|
||
<tr class="match"> | ||
<td>Project</td> | ||
<td>Brain^wpc-8620</td> | ||
<td>Brain^wpc-8620</td> | ||
</tr> | ||
|
||
<tr class="match"> | ||
<td>SequenceName</td> | ||
<td>HabitTask</td> | ||
<td>HabitTask</td> | ||
</tr> | ||
|
||
<tr class="mismatch"> | ||
<td>TR</td> | ||
<td>1300</td> | ||
<td>1400</td> | ||
</tr> | ||
|
||
<tr class="match"> | ||
<td>TE</td> | ||
<td>30</td> | ||
<td>30</td> | ||
</tr> | ||
|
||
<tr class="mismatch"> | ||
<td>FA</td> | ||
<td>60</td> | ||
<td>70</td> | ||
</tr> | ||
|
||
<tr class="match"> | ||
<td>iPAT</td> | ||
<td>GRAPPA</td> | ||
<td>GRAPPA</td> | ||
</tr> | ||
|
||
<tr class="match"> | ||
<td>Comments</td> | ||
<td>Unaliased MB3/PE4/LB SENSE1</td> | ||
<td>Unaliased MB3/PE4/LB SENS1</td> | ||
</tr> | ||
|
||
</table> | ||
</body> | ||
</html> |
Binary file added
BIN
+630 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.202208231445351851262117
Binary file not shown.
Binary file added
BIN
+616 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.202208231445352497562130
Binary file not shown.
Binary file added
BIN
+1.17 MB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022082314584544988383886
Binary file not shown.
Binary file added
BIN
+1.17 MB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022082314584569742884032
Binary file not shown.
Binary file added
BIN
+219 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022082315355424842882582
Binary file not shown.
Binary file added
BIN
+219 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022082315355424882582583
Binary file not shown.
Binary file added
BIN
+218 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022082315415621453329108
Binary file not shown.
Binary file added
BIN
+218 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022082315415621499729109
Binary file not shown.
Binary file added
BIN
+633 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.202208301451023180356667
Binary file not shown.
Binary file added
BIN
+619 KB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.202208301451023365156668
Binary file not shown.
Binary file added
BIN
+1.17 MB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022083015062151334886330
Binary file not shown.
Binary file added
BIN
+1.17 MB
modifiedDicoms/MR.1.3.12.2.1107.5.2.43.167046.2022083015062177324786482
Binary file not shown.
Oops, something went wrong.