Skip to content

Commit

Permalink
Add dataframe viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
gurayerus committed Dec 8, 2024
1 parent 0f92091 commit a505cbf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/viewer/pages/plot_sMRI_vars_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def panel_incsv() -> None:
)
st.session_state.is_updated["csv_plot"] = False

# Show input data
st.dataframe(st.session_state.plot_var["df_data"])


def panel_rename() -> None:
"""
Expand Down
11 changes: 11 additions & 0 deletions src/viewer/pages/prep_sMRI_dicomtonifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def panel_detect() -> None:
icon=":material/thumb_up:",
)

with st.expander('Show dicom metadata', expanded=False):
st.dataframe(st.session_state.df_dicoms)

@st.dialog("DICOM Series Detection") # type:ignore
def help_detect_series():
st.markdown(
Expand Down Expand Up @@ -237,6 +240,11 @@ def panel_extract() -> None:
num_nifti = utilio.get_file_count(
st.session_state.paths[st.session_state.sel_mod], ".nii.gz"
)

df_files = utilio.get_file_names(
st.session_state.paths[st.session_state.sel_mod], ".nii.gz"
)
num_nifti=df_files.shape[0]
if num_nifti > 0:
st.session_state.flags["dir_nifti"] = True
st.session_state.flags[st.session_state.sel_mod] = True
Expand All @@ -245,6 +253,9 @@ def panel_extract() -> None:
icon=":material/thumb_up:",
)

with st.expander('View NIFTI image list'):
st.dataframe(df_files)

@st.dialog("DICOM to Nifti Conversion") # type:ignore
def help_extract_nifti():
st.markdown(
Expand Down
14 changes: 14 additions & 0 deletions src/viewer/utils/utils_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import zipfile
from tkinter import filedialog
from typing import Any, BinaryIO, List, Optional
import pandas as pd

# https://stackoverflow.com/questions/64719918/how-to-write-streamlit-uploadedfile-to-temporary-in_dir-with-original-filenam
# https://gist.github.com/benlansdell/44000c264d1b373c77497c0ea73f0ef2
Expand Down Expand Up @@ -118,6 +119,19 @@ def get_file_count(folder_path: str, file_suff: str = "") -> int:
count += 1
return count

def get_file_names(folder_path: str, file_suff: str = "") -> pd.DataFrame:
f_names = []
if os.path.exists(folder_path):
if file_suff == "":
for root, dirs, files in os.walk(folder_path):
f_names.append(files)
else:
for root, dirs, files in os.walk(folder_path):
for file in files:
if file.endswith(file_suff):
f_names.append([file])
df_out = pd.DataFrame(columns=['FileName'], data=f_names)
return df_out

def get_file_list(folder_path: str, file_suff: str = "") -> List:
list_nifti: List[str] = []
Expand Down

0 comments on commit a505cbf

Please sign in to comment.