Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyze midsagittal lesion length and width #96

Merged
merged 28 commits into from
Jan 18, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
426b718
Add script to segment the spinal cord and lesions from T2w images and…
valosekj Sep 20, 2024
02e9321
Change logic how to save XLS files produced by sct_analyze_lesion. If…
valosekj Sep 20, 2024
7b87b5e
Remove forgotten '-ofolder ${PATH_RESULTS}/contrast-agnostic' from th…
valosekj Sep 20, 2024
6a06f86
Remove 'CUDA_VISIBLE_DEVICES=1 SCT_USE_GPU=1' for the contrast-agnost…
valosekj Sep 20, 2024
8d9b7b9
Use '-largest 1' to keep only the largest connected component. Contex…
valosekj Sep 20, 2024
1f647a6
Add README for the midsagittal lesion length and width analysis
valosekj Sep 20, 2024
813caae
Generate sagittal lesion QC report
valosekj Sep 21, 2024
3a88281
Remove the CA model because it does not work well on lumbar data with…
valosekj Oct 2, 2024
b02b11a
Add 02_read_xls_files.py script to aggregate lesion metrics across su…
valosekj Oct 2, 2024
80ec10d
Include measurements also for GT masks
valosekj Oct 2, 2024
23a1adc
Add QC for manual GT
valosekj Oct 2, 2024
02c33bb
Run sct_analyze_lesion on GT masks before running SCIseg inference. B…
valosekj Oct 3, 2024
79fd813
Add logging to better track number of processed subjects
valosekj Oct 3, 2024
d296080
Update docstring
valosekj Oct 3, 2024
def3d1f
Take into account multiple lesions
valosekj Oct 3, 2024
0a7aab6
Add script to generate figures
valosekj Oct 3, 2024
4a37ceb
Remove TODO -- already fixed in https://github.com/ivadomed/model_seg…
valosekj Oct 18, 2024
c6286a4
Add `args.pred_type` input arg
valosekj Nov 5, 2024
91ab72f
Read also 3D length, 3D width, and interpolated_midsagittal_slice
valosekj Nov 5, 2024
4904180
Description and help updates
valosekj Nov 5, 2024
6436d20
Renumbering
valosekj Nov 5, 2024
4574279
Add script to generate scatter plots with linear regression lines and…
valosekj Nov 5, 2024
a956456
Remove `03_generate_figures.py` as it is no longer used
valosekj Nov 5, 2024
421190c
Description update
valosekj Jan 18, 2025
8794c35
Remove unused variable
valosekj Jan 18, 2025
dec016c
'length_midsagittal_slice' --> 'length_interpolated_midsagittal_slice'
valosekj Jan 18, 2025
4b7fb4e
Update axis labels
valosekj Jan 18, 2025
baac0cd
Update description and comments
valosekj Jan 18, 2025
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
Prev Previous commit
Next Next commit
Read also 3D length, 3D width, and interpolated_midsagittal_slice
valosekj committed Nov 5, 2024
commit 91ab72fa6ca6d0f26c6c2da8e81c36c58627bcff
38 changes: 25 additions & 13 deletions midsagittal_measures/02_read_xls_files.py
Original file line number Diff line number Diff line change
@@ -157,26 +157,38 @@ def fetch_lesion_metrics(index, row, branch, df):
if len(df_lesion) > 1:
print(f'Subject: {row["participant_id"]} has more than one lesion. Aggregating the metrics across lesions.')
# Get the metrics
midsagittal_slice = str(df_lesion['midsagittal_spinal_cord_slice'].values[0])
# Sum length
# Sum midsagittal length and "3D" length
midsagittal_length = df_lesion['length_midsagittal_slice [mm]'].sum()
length = df_lesion['length [mm]'].sum()
# Take max width
midsagittal_width = df_lesion['width_midsagittal_slice [mm]'].max()
# Check if 'slice_' + midsagittal_slice + '_dorsal_bridge_width [mm]' is in the columns
if 'slice_' + midsagittal_slice + '_dorsal_bridge_width [mm]' in df_lesion.columns:
# Take min for dorsal and ventral bridges
dorsal_tissue_bridge = df_lesion['slice_' + midsagittal_slice + '_dorsal_bridge_width [mm]'].min()
ventral_tissue_bridge = df_lesion['slice_' + midsagittal_slice + '_ventral_bridge_width [mm]'].min()
else:
dorsal_tissue_bridge = np.nan
ventral_tissue_bridge = np.nan
width = df_lesion['width [mm]'].max()

# Save the values in the currently processed df row
df.at[index, 'midsagittal_slice'] = midsagittal_slice
df.at[index, 'length'] = length
df.at[index, 'width'] = width
df.at[index, 'midsagittal_length'] = midsagittal_length
df.at[index, 'midsagittal_width'] = midsagittal_width
df.at[index, 'dorsal_tissue_bridge'] = dorsal_tissue_bridge
df.at[index, 'ventral_tissue_bridge'] = ventral_tissue_bridge

if 'midsagittal_slice' in df_lesion.columns:
# midsagittal_slice = str(df_lesion['midsagittal_spinal_cord_slice'].values[0])
midsagittal_slice = str(df_lesion['midsagittal_slice'].values[0])
# Check if 'slice_' + midsagittal_slice + '_dorsal_bridge_width [mm]' is in the columns
if 'slice_' + midsagittal_slice + '_dorsal_bridge_width [mm]' in df_lesion.columns:
# Take min for dorsal and ventral bridges
dorsal_tissue_bridge = df_lesion['slice_' + midsagittal_slice + '_dorsal_bridge_width [mm]'].min()
ventral_tissue_bridge = df_lesion['slice_' + midsagittal_slice + '_ventral_bridge_width [mm]'].min()
else:
dorsal_tissue_bridge = np.nan
ventral_tissue_bridge = np.nan
# Save the values in the currently processed df row
df.at[index, 'midsagittal_slice'] = midsagittal_slice
df.at[index, 'dorsal_tissue_bridge'] = dorsal_tissue_bridge
df.at[index, 'ventral_tissue_bridge'] = ventral_tissue_bridge

if 'interpolated_midsagittal_slice' in df_lesion.columns:
df.at[index, 'dorsal_tissue_bridge'] = df_lesion['interpolated_dorsal_bridge_width [mm]'].values[0]
df.at[index, 'ventral_tissue_bridge'] = df_lesion['interpolated_ventral_bridge_width [mm]'].values[0]

return df