File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,12 @@ def read_roi(filename):
1515
1616 Returns
1717 -------
18- rois : list, shape(n_roi, 2)
19- A list of ROIs which each element is a list [roi name, elements]
18+ Rois : dict of str
19+ The Rois info info. Keys are:
20+ names : list of str
21+ the rois names.
22+ elements :list of int
23+ the indices of elements belonging to each rois (indice start to 1).
2024
2125 Warning
2226 -------
@@ -35,9 +39,13 @@ def read_roi(filename):
3539 print (f'Dimension_of_original_data: { n_orig } ' )
3640 n_roi = int (f .readline ().strip ())
3741 print (f'Number of ROI: { n_roi } ' )
38- rois = []
42+ rois_name = []
43+ rois_elements = []
3944 for _ in range (0 , n_roi ):
4045 roi_name = f .readline ().strip ()
4146 roi_elem = f .readline ().split (' ' )[:- 1 ]
42- rois .append ([roi_name , roi_elem ])
43- return (rois )
47+ rois_name .append (roi_name )
48+ rois_elements .append (roi_elem )
49+ Rois = {'names' : rois_name ,
50+ 'elements' : rois_elements }
51+ return (Rois )
Original file line number Diff line number Diff line change 1313def test_read_roi ():
1414 file_path = os .path .join (data_path , "sample_test_roi.rois" )
1515 rois = read_roi (file_path )
16- if not len (rois ) == 32 :
16+ if not len (rois ['names' ]) == 32 :
17+ raise AssertionError ()
18+ if not len (rois ['elements' ]) == 32 :
1719 raise AssertionError ()
You can’t perform that action at this time.
0 commit comments