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
Binary file added resources/atlases/muse/MNI152_1mm_LPS.nii.gz
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions resources/atlases/muse/MNI152_1mm_LPS_DLMUSE_Volumes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MRID,702,701,600,601,604,606,607,613,614,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,4,11,23,30,31,32,35,36,37,38,39,40,41,47,48,49,50,51,52,55,56,57,58,59,60,61,62,71,72,73,75,76,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,100,101,102,103,104,105,106,107,108,109,112,113,114,115,116,117,118,119,120,121,122,123,124,125,128,129,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
MNI152_1mm_LPS,1834388.0,1675775.0,156792.0,889961.0,736228.0,439610.0,359382.0,437713.0,361371.0,15475.0,184013.0,75759.0,547803.0,47518.0,169777.0,278444.0,294927.0,23866.0,85651.0,37813.0,271866.0,24081.0,84073.0,141765.0,147374.0,10771.0,85724.0,37946.0,275937.0,23437.0,85704.0,136679.0,147553.0,9834.0,25255.0,21377.0,15076.0,262551.0,285252.0,47518.0,94980.0,74797.0,138227.0,140217.0,141192.0,153735.0,12702.0,10786.0,7456.0,130896.0,140970.0,24081.0,47128.0,36945.0,69985.0,71780.0,71081.0,76293.0,12553.0,10591.0,7620.0,131655.0,144282.0,23437.0,47852.0,37852.0,68242.0,68437.0,70111.0,77442.0,27463.0,17813.0,144119.0,51794.0,21362.0,35460.0,12058.0,12048.0,40787.0,42145.0,104562.0,33665.0,21202.0,105779.0,14211.0,13711.0,8841.0,71910.0,25451.0,10983.0,18050.0,6031.0,6266.0,20462.0,20400.0,53408.0,16577.0,10284.0,53205.0,7592.0,13752.0,8972.0,72209.0,26343.0,10379.0,17410.0,6027.0,5782.0,20325.0,21745.0,51154.0,17088.0,10918.0,52574.0,6619.0,909.0,2352.0,613.0,695.0,1274.0,1283.0,25720.0,4191.0,4143.0,66090.0,66082.0,19634.0,19569.0,5231.0,4873.0,422.0,343.0,9412.0,10428.0,2027.0,1983.0,5722.0,5881.0,10591.0,10786.0,6104.0,6369.0,5798.0,2993.0,3847.0,713.0,677.0,144282.0,140970.0,37852.0,36945.0,68437.0,71780.0,77442.0,76293.0,609.0,785.0,4252.0,3887.0,2759.0,2784.0,15475.0,6148.0,6962.0,5863.0,5877.0,2584.0,1988.0,13505.0,12733.0,4607.0,4942.0,5326.0,5174.0,6403.0,5991.0,2392.0,2421.0,2385.0,2306.0,3276.0,3036.0,10918.0,10284.0,2867.0,2898.0,8224.0,6831.0,15225.0,15708.0,10735.0,9467.0,2315.0,2569.0,6374.0,5779.0,2700.0,2897.0,23633.0,24627.0,5118.0,6668.0,4971.0,5331.0,1241.0,1039.0,4027.0,3608.0,9687.0,7715.0,17816.0,18408.0,2440.0,2494.0,5782.0,6266.0,4138.0,4630.0,1981.0,2265.0,4888.0,5309.0,15847.0,15538.0,3635.0,3610.0,3109.0,2964.0,2668.0,3503.0,12788.0,16179.0,3882.0,3823.0,2403.0,2677.0,16634.0,16003.0,2505.0,3056.0,1592.0,1684.0,18274.0,16557.0,5470.0,6649.0,11625.0,12635.0,4543.0,4469.0,13236.0,11861.0,8463.0,8453.0,11070.0,10636.0,4273.0,4792.0,1711.0,1859.0
16,769 changes: 16,769 additions & 0 deletions resources/reference_data/centiles/nichart_centiles_AD-All.csv

Large diffs are not rendered by default.

16,239 changes: 16,239 additions & 0 deletions resources/reference_data/centiles/nichart_centiles_AD-Females.csv

Large diffs are not rendered by default.

15,684 changes: 15,684 additions & 0 deletions resources/reference_data/centiles/nichart_centiles_AD-Males.csv

Large diffs are not rendered by default.

22,424 changes: 22,424 additions & 0 deletions resources/reference_data/centiles/nichart_centiles_CN-All.csv

Large diffs are not rendered by default.

22,424 changes: 22,424 additions & 0 deletions resources/reference_data/centiles/nichart_centiles_CN-Females.csv

Large diffs are not rendered by default.

22,384 changes: 22,384 additions & 0 deletions resources/reference_data/centiles/nichart_centiles_CN-Males.csv

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions src/viewer/gui/utils_mriview.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,106 @@ def show_img_slices(img, scroll_axis, sel_axis_bounds, orientation, wimg = None)
else:
st.image(img[:, :, slice_index], width=wimg)

def panel_view_seg_refplot(ptype):
'''
Panel to display segmented image overlaid on underlay image for the reference data
'''
logger.debug('Panel: View Segmentation for the Ref Plot')

ss = st.session_state
pdict = ss[ptype]

ylab = pdict['selected']['ylab']
# ylab = 'DL_MUSE_Volume_GM'


# Find roi indices
col_dict = pdict['data']['col_dict']
roi = col_dict.renamed_to_roi_index(ylab)

if roi is None:
logger.debug('ROI not found')
return
roi_indices = st.session_state.dicts['muse']['derived'].get(roi, [roi])
if roi_indices is None or len(roi_indices)<=0:
logger.debug('No ROI indices found')
return

tab1, tab2 = st.tabs(
[':material/visibility_off:', 'Options'],
on_change='rerun',
key='_tabs_mri_controls',
)

if tab2.open:
with tab2:
with st.container(border=True):
select_mriplot_settings(ptype)

if pdict['settings']['mri_ulay'] is None:
st.toast('Underlay image not found!')
return

if pdict['settings']['mri_olay'] is None:
st.toast('Overlay image not found!')
pdict['settings']['mri_flag_olay'] = False
st.rerun()

# Show images
with st.container(border=True):
try:
img, mask, img_masked = prep_image_and_olay(
pdict['settings']['mri_ulay'],
pdict['settings']['mri_olay'],
list_rois=roi_indices,
crop_to_mask=pdict['settings']['mri_flag_crop']
)
except Exception as exc:
st.warning(f'Could not read image files! {exc}')
st.write(pdict['settings']['mri_ulay'])
st.write(pdict['settings']['mri_olay'])
st.write(pdict['settings'])
return

img_bounds = detect_mask_bounds(mask)

pdict['settings']['mri_orient'] = ['axial']
nviews = len(pdict['settings']['mri_orient'])
if nviews == 0:
return
cols = st.columns(nviews)
for i, sel_orient in enumerate(pdict['settings']['mri_orient']):
with cols[i]:
ind_view = img_views.index(sel_orient)
if pdict['settings']['mri_olay'] is None or pdict['settings']['mri_flag_olay'] is False:
show_img_slices(
img, ind_view, img_bounds[ind_view, :], sel_orient
)
else:
show_img_slices(
img_masked, ind_view, img_bounds[ind_view, :], sel_orient
)





def panel_view_seg(ptype):
'''
Panel to display segmented image overlaid on underlay image
'''
logger.debug('Panel: View Segmentation')

if ptype == 'ref_plots':
panel_view_seg_refplot(ptype)
return

ss = st.session_state
pdict = ss[ptype]

# logger.debug(pdict)
# st.write(pdict)

mrid = pdict['selected']['mrid']
ylab = pdict['selected']['ylab']

Expand Down
4 changes: 4 additions & 0 deletions src/viewer/gui/utils_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def select_centile_type(ptype):

list_types = pdict['settings'].get('cent_types', [])
vname = f"{ptype}.data.cent_type"

# st.write(pdict)
# st.write((f"Centile types: {list_types}") )

utilwd.my_selectbox(
vname, list_types, 'Centile Type'
)
Expand Down
27 changes: 23 additions & 4 deletions src/viewer/gui/utils_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def init_plots():
}

# Set plot data params
pref = os.path.join(st.session_state.paths['centiles'], 'nichart_centiles_dlmuse')
ctype = 'CN'
pref = os.path.join(st.session_state.paths['centiles'], 'nichart_centiles')
# ctype = 'dlmuse_CN'
ctype = 'CN-All'
dtmp = {
"cent_type": ctype,
"cent_path": pref,
Expand Down Expand Up @@ -137,7 +138,20 @@ def init_ref_plots():
plots = init_plots()

# Set centile types
plots['settings']['cent_types'] = ["None", "CN", "CN-Males", "CN-Females"]
# plots['settings']['cent_types'] = ["CN", "CN-Males", "CN-Females"]
plots['settings']['cent_types'] = [
"None",
"CN-All", "CN-Males", "CN-Females",
"AD-All", "AD-Males", "AD-Females",
]
plots['settings']['mri_ulay'] = os.path.join(
st.session_state.paths['resources'], 'atlases',
'muse', 'MNI152_1mm_LPS.nii.gz'
)
plots['settings']['mri_olay'] = os.path.join(
st.session_state.paths['resources'], 'atlases',
'muse', 'MNI152_1mm_LPS_DLMUSE.nii.gz'
)

# Save in session state
st.session_state['ref_plots'] = plots.copy()
Expand All @@ -154,7 +168,12 @@ def init_user_plots():
plots = init_plots()

# Set centile types
plots['settings']['cent_types'] = ["CN", "CN-Males", "CN-Females"]
# plots['settings']['cent_types'] = ["CN", "CN-Males", "CN-Females"]
plots['settings']['cent_types'] = [
"None",
"CN-All", "CN-Males", "CN-Females",
"AD-All", "AD-Males", "AD-Females",
]

# Save in session state
st.session_state['user_plots'] = plots.copy()
Expand Down