Imageomics / Andromeda

A website that enables users to explore high-dimensional image data
http://andromeda.imageomics.org/
MIT License
2 stars 1 forks source link

Fix 500/KeyError for mockData_v1.csv #28

Closed johnbradley closed 1 year ago

johnbradley commented 1 year ago

When clicking "Visualize Data" with datasets/testData/mockData_v1.csv a 500 error is returned. The logs for the flask app show the following error:

...
  File "/src/Andromeda/andromeda/main.py", line 74, in dimensional_reduction
    weights, image_coordinates = dataset.dimensional_reduction(json_payload["weights"])
  File "/src/Andromeda/andromeda/dataset.py", line 74, in dimensional_reduction
    normalized_df = self.get_normalized_dataframe()
  File "/src/Andromeda/andromeda/dataset.py", line 61, in get_normalized_dataframe
    return df[self.selected_columns]
  File "/src/Andromeda/andromeda/venv/lib/python3.8/site-packages/pandas/core/frame.py", line 3766, in __getitem__
    indexer = self.columns._get_indexer_strict(key, "columns")[1]
  File "/src/Andromeda/andromeda/venv/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 5876, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)
  File "/src/Andromeda/andromeda/venv/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 5938, in _raise_if_missing
    raise KeyError(f"{not_found} not in index")
KeyError: "['sat_maxRed', 'sat_maxGreen', 'sat_maxBlue'] not in index"

If these three fields are unchecked under Configure Visualization the error does not occur. These three columns only contain the value 1.

johnbradley commented 1 year ago

The function normalized_df() removes any columns where all the values are the same: https://github.com/Imageomics/Andromeda/blob/836608c1cf2925e437e0412d6c08d2c5522f6ba7/andromeda/andromeda.py#L25 This logic came from Andromeda_IMG.ipynb.

johnbradley commented 1 year ago

Perhaps a good fix would be to remove columns with all the same value from the list of selectable columns. We could add details about why some columns aren't selectable(not numeric or all the same value).

hlapp commented 1 year ago

I agree - numeric columns with zero variance should be assumed to be useless for Andromeda.