Skip to content

Commit 0a6ab03

Browse files
committed
Added RMR
1 parent 6e7734f commit 0a6ab03

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

compress_rtp/utils/get_sparse_only.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
import scipy
44

55

6-
def get_sparse_only(matrix, threshold_perc, compression='naive'):
6+
def get_sparse_only(matrix: np.ndarray, threshold_perc: float = 1, compression: str = 'naive'):
7+
"""
8+
Get sparse matrix using threshold and different methods
9+
:param matrix: matrix to be sparsified
10+
:param threshold_perc: threshold for matrix sparsification
11+
:param compression: Method of Sparsification
12+
13+
:return: Sparse influence matrix
14+
"""
715
threshold = np.max(matrix) * threshold_perc*0.01
816
if compression == 'rmr':
917
copy_matrix = matrix.copy()

examples/matrix_sparse_only.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"metadata": {},
125125
"outputs": [],
126126
"source": [
127-
"# run optimization with naive thresold of 1% of max(A) and no low rank\n",
127+
"# run optimization with naive thresold of 1% of max(A)\n",
128128
"# create cvxpy problem using the clinical criteria and optimization parameters\n",
129129
"A = deepcopy(inf_matrix.A)\n",
130130
"S_sparse = get_sparse_only(matrix=A, threshold_perc=1)\n",
@@ -278,6 +278,7 @@
278278
}
279279
],
280280
"source": [
281+
"# Run IMRT fluence map optimization\n",
281282
"opt = pp.Optimization(my_plan, inf_matrix=inf_matrix, opt_params=opt_params)\n",
282283
"opt.create_cvxpy_problem()\n",
283284
"sol_sparse_naive = opt.solve(solver='MOSEK', verbose=True)"
@@ -296,7 +297,7 @@
296297
"id": "005283cc",
297298
"metadata": {},
298299
"source": [
299-
"Instead of optimizing the plan using sparse influence matrix $ S $ we optimize it using sparse matrix using RMR method discussed in (RMR)[]"
300+
"Now instead of optimizing the plan using sparse influence matrix $ S $ we optimize it using sparse matrix obtained using RMR method discussed in (RMR)[]"
300301
]
301302
},
302303
{

0 commit comments

Comments
 (0)