Skip to content

Commit

Permalink
Edit position of help and other buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
gurayerus committed Dec 8, 2024
1 parent a505cbf commit 8da457a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 24 deletions.
28 changes: 18 additions & 10 deletions src/viewer/pages/prep_sMRI_dicomtonifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ def help_working_dir():
"""
)

if st.button('Get help 🤔', key='key_btn_working_dir'):
help_working_dir()

col1, col2 = st.columns([0.5, 0.1])
with col2:
if st.button('Get help 🤔', key='key_btn_working_dir', use_container_width=True):
help_working_dir()

def panel_indicoms() -> None:
"""
Expand Down Expand Up @@ -128,8 +129,10 @@ def help_in_dicoms():
"""
)

if st.button('Get help 🤔', key='key_btn_help_in_dicoms'):
help_in_dicoms()
col1, col2 = st.columns([0.5, 0.1])
with col2:
if st.button('Get help 🤔', key='key_btn_help_in_dicoms', use_container_width=True):
help_in_dicoms()

def panel_detect() -> None:
"""
Expand Down Expand Up @@ -182,8 +185,10 @@ def help_detect_series():
"""
)

if st.button('Get help 🤔', key='key_btn_help_detect_series'):
help_detect_series()
col1, col2 = st.columns([0.5, 0.1])
with col2:
if st.button('Get help 🤔', key='key_btn_help_detect_series', use_container_width=True):
help_detect_series()


def panel_extract() -> None:
Expand Down Expand Up @@ -266,8 +271,10 @@ def help_extract_nifti():
"""
)

if st.button('Get help 🤔', key='key_btn_help_extract_nifti'):
help_extract_nifti()
col1, col2 = st.columns([0.5, 0.1])
with col2:
if st.button('Get help 🤔', key='key_btn_help_extract_nifti', use_container_width=True):
help_extract_nifti()


def panel_view() -> None:
Expand Down Expand Up @@ -353,8 +360,9 @@ def panel_view() -> None:
):
with blocks[i]:
ind_view = utilni.img_views.index(tmp_orient)
size_auto = True
utilst.show_img3D(
img, ind_view, img_bounds[ind_view, :], tmp_orient
img, ind_view, img_bounds[ind_view, :], tmp_orient, size_auto
)


Expand Down
40 changes: 26 additions & 14 deletions src/viewer/utils/utils_st.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# from wfork_streamlit_profiler import Profiler
# import pyinstrument

COL_LEFT = 3
COL_LEFT = 5
COL_RIGHT_EMPTY = 0.01
COL_RIGHT_BUTTON = 1

Expand Down Expand Up @@ -88,7 +88,7 @@ def user_input_filename(
path_dir = path_last
tmpcol = st.columns((COL_LEFT, COL_RIGHT_BUTTON), vertical_alignment="bottom")
with tmpcol[1]:
if st.button(label_btn, key=f"key_btn_{key_st}"):
if st.button(label_btn, key=f"key_btn_{key_st}", use_container_width=True):
# path_curr, path_dir = utilio.browse_file(path_dir)
out_file = utilio.browse_file(path_dir)
if out_file is not None and os.path.exists(out_file):
Expand Down Expand Up @@ -122,7 +122,7 @@ def user_input_foldername(

# Button to select folder
with tmpcol[1]:
if st.button(label_btn, key=f"btn_{key_st}"):
if st.button(label_btn, key=f"btn_{key_st}", use_container_width=True):
out_str = utilio.browse_folder(path_last)

if out_str is not None and os.path.exists(out_str):
Expand Down Expand Up @@ -151,7 +151,11 @@ def user_input_foldername(


def show_img3D(
img: np.ndarray, scroll_axis: Any, sel_axis_bounds: Any, img_name: str
img: np.ndarray,
scroll_axis: Any,
sel_axis_bounds: Any,
img_name: str,
size_auto: bool,
) -> None:
"""
Display a 3D img
Expand All @@ -167,17 +171,25 @@ def show_img3D(
)

# Extract the slice and display it
w_img = (
st.session_state.mriview_const["w_init"]
* st.session_state.mriview_var["w_coeff"]
)
if scroll_axis == 0:
# st.image(img[slice_index, :, :], use_column_width=True)
st.image(img[slice_index, :, :], width=w_img)
elif scroll_axis == 1:
st.image(img[:, slice_index, :], width=w_img)
if size_auto:
if scroll_axis == 0:
st.image(img[slice_index, :, :], use_column_width=True)
elif scroll_axis == 1:
st.image(img[:, slice_index, :], use_column_width=True)
else:
st.image(img[:, :, slice_index], use_column_width=True)
else:
st.image(img[:, :, slice_index], width=w_img)
w_img = (
st.session_state.mriview_const["w_init"]
* st.session_state.mriview_var["w_coeff"]
)
if scroll_axis == 0:
# st.image(img[slice_index, :, :], use_column_width=True)
st.image(img[slice_index, :, :], width=w_img)
elif scroll_axis == 1:
st.image(img[:, slice_index, :], width=w_img)
else:
st.image(img[:, :, slice_index], width=w_img)


def util_panel_workingdir(app_type: str) -> None:
Expand Down

0 comments on commit 8da457a

Please sign in to comment.