Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed static files distribution with pip install #29

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
3 changes: 1 addition & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
include methcomp/static/seg.csv
include methcomp/static/seg600.png
include methcomp/static/*
10 changes: 7 additions & 3 deletions methcomp/glucose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ def __init__(
reference,
test,
units,
file_name,
x_title,
y_title,
graph_title,
Expand All @@ -1238,6 +1239,7 @@ def __init__(
self.reference: np.array = np.asarray(reference)
self.test: np.array = np.asarray(test)
self.units = units
self.file_name = file_name
self.graph_title: str = graph_title
self.x_title: str = x_title
self.y_title: str = y_title
Expand Down Expand Up @@ -1284,7 +1286,7 @@ def _calc_error_score(self):
_zones = []
from . import static # temporary fix

data = np.loadtxt(pkg_resources.open_text(static, "seg.csv"))
data = np.loadtxt(pkg_resources.open_text(static, self.file_name))
_zones = np.array([data.T[int(p), int(t)] for p, t in zip(pred, ref)])

return _zones
Expand Down Expand Up @@ -1424,6 +1426,7 @@ def seg(
reference,
test,
units,
file_name,
x_label=None,
y_label=None,
title=None,
Expand Down Expand Up @@ -1489,6 +1492,7 @@ def seg(
reference,
test,
units,
file_name,
x_label,
y_label,
title,
Expand All @@ -1510,7 +1514,7 @@ def seg(
return ax


def segscores(reference, test, units):
def segscores(reference, test, units, file_name="seg.csv"):
"""Provides the raw error values as depicted by the
surveillance error grid analysis for each point in the reference and test datasets.

Expand All @@ -1534,7 +1538,7 @@ def segscores(reference, test, units):

# obtain zones from a Clarke reference object
_zones = _SEG(
reference, test, units, None, None, None, None, None, None, None
reference, test, units, file_name, None, None, None, None, None, None, None
)._calc_error_score()

return _zones
600 changes: 600 additions & 0 deletions methcomp/static/smoothed_seg_sigma_1.csv

Large diffs are not rendered by default.

600 changes: 600 additions & 0 deletions methcomp/static/smoothed_seg_sigma_10.csv

Large diffs are not rendered by default.

600 changes: 600 additions & 0 deletions methcomp/static/smoothed_seg_sigma_15.csv

Large diffs are not rendered by default.

600 changes: 600 additions & 0 deletions methcomp/static/smoothed_seg_sigma_2.csv

Large diffs are not rendered by default.

600 changes: 600 additions & 0 deletions methcomp/static/smoothed_seg_sigma_20.csv

Large diffs are not rendered by default.

600 changes: 600 additions & 0 deletions methcomp/static/smoothed_seg_sigma_5.csv

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@
packages=PACKAGES,
classifiers=CLASSIFIERS,
include_package_data=True,
package_data={
'methcomp': ['static/*'], # Include all files in the static folder
},
)
17 changes: 17 additions & 0 deletions smoothen_seg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import numpy as np
import pandas as pd
from scipy.ndimage import gaussian_filter

# Step 1: Load the matrix from a CSV file
matrix = pd.read_csv('methcomp/static/seg.csv', header=None, delimiter=' ', dtype=str)
matrix = matrix.apply(pd.to_numeric, errors='coerce').fillna(0).values

sigmas = [1.0, 2.0, 5.0]

for sigma in sigmas:
# Step 2: Apply a Gaussian filter to smoothen the matrix
smoothed_matrix = gaussian_filter(matrix, sigma=sigma)

# Step 3: Save the smoothed matrix as a new CSV file
pd.DataFrame(smoothed_matrix).to_csv(f'methcomp/static/smoothed_seg_{sigma}.csv', index=False, header=False)