Spaces:
Runtime error
Runtime error
Vamsi Thiriveedhi
commited on
Commit
·
2c67485
1
Parent(s):
1c4dd7a
enh: add dual end slider for voxel number values
Browse files- filter_data_app.py +11 -8
- test.py +6 -0
filter_data_app.py
CHANGED
@@ -44,12 +44,14 @@ def filter_data(df, filters):
|
|
44 |
if value is not None and col != 'radiomics_feature': # Exclude radiomics_feature from filtering
|
45 |
if col == 'connected_volumes' and value:
|
46 |
df = df.filter((pl.col(col) <= value) & (pl.col(col).is_not_null()))
|
|
|
|
|
47 |
else:
|
48 |
df = df.filter(pl.col(col) == value)
|
49 |
# Filter based on radiomics feature
|
50 |
radiomics_feature = filters.get('radiomics_feature')
|
51 |
if radiomics_feature:
|
52 |
-
df = df.filter(pl.col(radiomics_feature)
|
53 |
return df
|
54 |
|
55 |
# Function to create an UpSet plot for failed checks
|
@@ -112,7 +114,7 @@ def main():
|
|
112 |
'connected_volumes': None,
|
113 |
'laterality': None,
|
114 |
'radiomics_feature': 'Volume from Voxel Summation', # Default radiomics feature
|
115 |
-
'
|
116 |
}
|
117 |
|
118 |
filters = st.session_state.filters
|
@@ -126,7 +128,7 @@ def main():
|
|
126 |
'connected_volumes': None,
|
127 |
'laterality': None,
|
128 |
#'radiomics_feature': 'Volume from Voxel Summation'
|
129 |
-
'
|
130 |
})
|
131 |
st.session_state.filters = filters
|
132 |
|
@@ -134,7 +136,6 @@ def main():
|
|
134 |
filters[filter_name] = value
|
135 |
st.session_state.filters = filters
|
136 |
|
137 |
-
|
138 |
# Radiomics feature selection
|
139 |
radiomics_feature_options = [
|
140 |
'Volume from Voxel Summation', # Default option
|
@@ -195,7 +196,6 @@ def main():
|
|
195 |
laterality_options = [""] + filtered_df['laterality'].unique().to_list()
|
196 |
voxel_num_options = filtered_df.filter(col('voxel_num').is_not_null()).select('voxel_num').unique().to_pandas().iloc[:, 0].tolist()
|
197 |
|
198 |
-
|
199 |
laterality = st.selectbox(
|
200 |
"Laterality",
|
201 |
options=laterality_options,
|
@@ -237,13 +237,16 @@ def main():
|
|
237 |
on_change=lambda: apply_filter('connected_volumes', st.session_state.connected_volumes)
|
238 |
)
|
239 |
|
240 |
-
|
241 |
min_value=min(voxel_num_options),
|
242 |
max_value=max(voxel_num_options),
|
243 |
-
key='
|
244 |
-
|
|
|
|
|
245 |
|
246 |
st.session_state.filters = filters
|
|
|
247 |
|
248 |
if laterality:
|
249 |
body_part_df = df.filter((col('bodyPart') == lit(body_part)) & (col('laterality') == lit(laterality)))
|
|
|
44 |
if value is not None and col != 'radiomics_feature': # Exclude radiomics_feature from filtering
|
45 |
if col == 'connected_volumes' and value:
|
46 |
df = df.filter((pl.col(col) <= value) & (pl.col(col).is_not_null()))
|
47 |
+
elif col == 'voxel_num_values' and value:
|
48 |
+
df = df.filter((pl.col('voxel_num') >= value[0]) & (pl.col('voxel_num') <= value[1]))
|
49 |
else:
|
50 |
df = df.filter(pl.col(col) == value)
|
51 |
# Filter based on radiomics feature
|
52 |
radiomics_feature = filters.get('radiomics_feature')
|
53 |
if radiomics_feature:
|
54 |
+
df = df.filter(pl.col(radiomics_feature).is_not_null()) # Filter where the radiomics feature is not None
|
55 |
return df
|
56 |
|
57 |
# Function to create an UpSet plot for failed checks
|
|
|
114 |
'connected_volumes': None,
|
115 |
'laterality': None,
|
116 |
'radiomics_feature': 'Volume from Voxel Summation', # Default radiomics feature
|
117 |
+
'voxel_num_values': None
|
118 |
}
|
119 |
|
120 |
filters = st.session_state.filters
|
|
|
128 |
'connected_volumes': None,
|
129 |
'laterality': None,
|
130 |
#'radiomics_feature': 'Volume from Voxel Summation'
|
131 |
+
'voxel_num_values':None,
|
132 |
})
|
133 |
st.session_state.filters = filters
|
134 |
|
|
|
136 |
filters[filter_name] = value
|
137 |
st.session_state.filters = filters
|
138 |
|
|
|
139 |
# Radiomics feature selection
|
140 |
radiomics_feature_options = [
|
141 |
'Volume from Voxel Summation', # Default option
|
|
|
196 |
laterality_options = [""] + filtered_df['laterality'].unique().to_list()
|
197 |
voxel_num_options = filtered_df.filter(col('voxel_num').is_not_null()).select('voxel_num').unique().to_pandas().iloc[:, 0].tolist()
|
198 |
|
|
|
199 |
laterality = st.selectbox(
|
200 |
"Laterality",
|
201 |
options=laterality_options,
|
|
|
237 |
on_change=lambda: apply_filter('connected_volumes', st.session_state.connected_volumes)
|
238 |
)
|
239 |
|
240 |
+
voxel_num_values = st.slider("Voxel Number",
|
241 |
min_value=min(voxel_num_options),
|
242 |
max_value=max(voxel_num_options),
|
243 |
+
key='voxel_num_values',
|
244 |
+
value=(min(voxel_num_options),max(voxel_num_options)),
|
245 |
+
on_change=lambda: apply_filter('voxel_num_values', st.session_state.voxel_num_values)
|
246 |
+
)
|
247 |
|
248 |
st.session_state.filters = filters
|
249 |
+
filtered_df = filter_data(df, filters)
|
250 |
|
251 |
if laterality:
|
252 |
body_part_df = df.filter((col('bodyPart') == lit(body_part)) & (col('laterality') == lit(laterality)))
|
test.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
values = st.slider(
|
4 |
+
"Select a range of values",
|
5 |
+
0.0, 100.0, (25.0, 75.0))
|
6 |
+
st.write("Values:", values)
|