Loading src/gui.py +22 −11 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ class Ui(QtWidgets.QMainWindow): # DONE 6 - what if multiple same named widgets? add groupid to widgetid? # 6.5 - what if multiple same named widgets? outputfile names should include widgetgroup id? # DONE 7 - multiple commentBox not supported (yes, but events need to be solved) # 8 - If filename not in input file, detect images (currently fails) # DONE 8 - If filename not in input file, detect images (currently fails) # DONE 9 - Shortcuts not working # Find checkboxes: Loading Loading @@ -276,7 +276,7 @@ class Ui(QtWidgets.QMainWindow): # Draw GUI: self.show() self.load_row() # self.load_row() # not needed first row loaded on fillList # List helpers: Loading Loading @@ -357,13 +357,20 @@ class Ui(QtWidgets.QMainWindow): def save_row(self) -> None: index = self.fileList.selectionModel().selectedRows()[0].row() try: if self.has_groups: fn = self.fileList.item(index, 5).text() else: fn = self.fileList.item(index, 4).text() # if self.has_groups: # fn = self.fileList.item(index, 5).text() # else: # fn = self.fileList.item(index, 4).text() # Identify row by filename (better than index) item_index = self.df['filename'] == fn # item_index = self.df['filename'] == fn if self.has_groups: grp = int(self.fileList.item(index, 0).text()) gal = int(self.fileList.item(index, 1).text()) item_index = (self.df['group']==grp) & (self.df['galaxy']==gal) else: gal = int(self.fileList.item(index, 0).text()) item_index = self.df['galaxy']==gal self.df.loc[item_index, 'processed'] = True if self.has_groups: Loading Loading @@ -412,11 +419,15 @@ class Ui(QtWidgets.QMainWindow): index = self.fileList.selectionModel().selectedRows()[0].row() try: if self.has_groups: fn = self.fileList.item(index, 5).text() grp = int(self.fileList.item(index, 0).text()) gal = int(self.fileList.item(index, 1).text()) item_index = (self.df['group']==grp) & (self.df['galaxy']==gal) else: fn = self.fileList.item(index, 4).text() gal = int(self.fileList.item(index, 0).text()) item_index = self.df['galaxy']==gal item = self.df.loc[self.df['filename'] == fn] item = self.df.loc[item_index] self.imgPath = item['fullpath'].item() windowTitle = '' Loading src/utils.py +23 −5 Original line number Diff line number Diff line Loading @@ -37,7 +37,9 @@ def getOptions(version): parser.add_argument("-l", "--list", action="store_true", help="List selected files only and exit.\n") parser.add_argument('-i', '--inputfile', default='galaxies.csv', type=dir_file, help="Galaxy database file in *.csv format.\n") help="""Galaxy database file in *.csv format. Minimum required columns: ['galaxy', 'ra', 'dec']. Recomended columns: ['group', 'galaxy', 'ra', 'dec', 'filename']""") parser.add_argument('group', metavar='GROUP', type=int, nargs='*', help="Group number. Selects images with name format: img_<group>_*.png\n") Loading Loading @@ -137,6 +139,22 @@ def readInputFile(fname:str) -> pd.DataFrame: sortby.insert(0, 'group') df = df.sort_values(by=sortby) if 'filename' not in df.columns: imgpath = Path(args.path) df['filename'] = '' for i, row in df.iterrows(): if 'group' in df.columns: imgfile = f'img_{row.group}_{row.galaxy}.*' else: imgfile = f'img_*_{row.galaxy}.*' image = glob.glob(f"{imgpath.absolute()}/{imgfile}") if len(image)>0: df.loc[i, 'filename'] = image[0] not_found = sum(df['filename']=='') if not_found >0: print(f'\nWARNING: {not_found} images where not found. Check if the provided path is correct. Or download the images using the provided tool.') else: print('Done!') return df Loading @@ -144,7 +162,7 @@ def createInputFile(imgpath:str, fname:str) -> pd.DataFrame: print(f'INFO:\tCreating {fname} file... ', end='', flush=True) df = pd.DataFrame(columns=INPUTCOLUMNS) if imgpath: for file in Path(imgpath).glob('img_*_*.png'): for file in Path(imgpath).glob('img_*_*.*'): entry = { 'group': int(file.stem.split('_')[1]), 'galaxy': int(file.stem.split('_')[2]), Loading @@ -154,11 +172,11 @@ def createInputFile(imgpath:str, fname:str) -> pd.DataFrame: } df = pd_concat(df, entry) #groups = groups.append(entry, ignore_index=True) # sort # if groups not defined if sum(df["groups"] == '-') == len(df): df.drop("groups", axis=1, inplace=True) INPUTCOLUMNS.remove("groups") # sort sortby=[] if 'galaxy' in df.columns: sortby.insert(0, 'galaxy') Loading Loading
src/gui.py +22 −11 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ class Ui(QtWidgets.QMainWindow): # DONE 6 - what if multiple same named widgets? add groupid to widgetid? # 6.5 - what if multiple same named widgets? outputfile names should include widgetgroup id? # DONE 7 - multiple commentBox not supported (yes, but events need to be solved) # 8 - If filename not in input file, detect images (currently fails) # DONE 8 - If filename not in input file, detect images (currently fails) # DONE 9 - Shortcuts not working # Find checkboxes: Loading Loading @@ -276,7 +276,7 @@ class Ui(QtWidgets.QMainWindow): # Draw GUI: self.show() self.load_row() # self.load_row() # not needed first row loaded on fillList # List helpers: Loading Loading @@ -357,13 +357,20 @@ class Ui(QtWidgets.QMainWindow): def save_row(self) -> None: index = self.fileList.selectionModel().selectedRows()[0].row() try: if self.has_groups: fn = self.fileList.item(index, 5).text() else: fn = self.fileList.item(index, 4).text() # if self.has_groups: # fn = self.fileList.item(index, 5).text() # else: # fn = self.fileList.item(index, 4).text() # Identify row by filename (better than index) item_index = self.df['filename'] == fn # item_index = self.df['filename'] == fn if self.has_groups: grp = int(self.fileList.item(index, 0).text()) gal = int(self.fileList.item(index, 1).text()) item_index = (self.df['group']==grp) & (self.df['galaxy']==gal) else: gal = int(self.fileList.item(index, 0).text()) item_index = self.df['galaxy']==gal self.df.loc[item_index, 'processed'] = True if self.has_groups: Loading Loading @@ -412,11 +419,15 @@ class Ui(QtWidgets.QMainWindow): index = self.fileList.selectionModel().selectedRows()[0].row() try: if self.has_groups: fn = self.fileList.item(index, 5).text() grp = int(self.fileList.item(index, 0).text()) gal = int(self.fileList.item(index, 1).text()) item_index = (self.df['group']==grp) & (self.df['galaxy']==gal) else: fn = self.fileList.item(index, 4).text() gal = int(self.fileList.item(index, 0).text()) item_index = self.df['galaxy']==gal item = self.df.loc[self.df['filename'] == fn] item = self.df.loc[item_index] self.imgPath = item['fullpath'].item() windowTitle = '' Loading
src/utils.py +23 −5 Original line number Diff line number Diff line Loading @@ -37,7 +37,9 @@ def getOptions(version): parser.add_argument("-l", "--list", action="store_true", help="List selected files only and exit.\n") parser.add_argument('-i', '--inputfile', default='galaxies.csv', type=dir_file, help="Galaxy database file in *.csv format.\n") help="""Galaxy database file in *.csv format. Minimum required columns: ['galaxy', 'ra', 'dec']. Recomended columns: ['group', 'galaxy', 'ra', 'dec', 'filename']""") parser.add_argument('group', metavar='GROUP', type=int, nargs='*', help="Group number. Selects images with name format: img_<group>_*.png\n") Loading Loading @@ -137,6 +139,22 @@ def readInputFile(fname:str) -> pd.DataFrame: sortby.insert(0, 'group') df = df.sort_values(by=sortby) if 'filename' not in df.columns: imgpath = Path(args.path) df['filename'] = '' for i, row in df.iterrows(): if 'group' in df.columns: imgfile = f'img_{row.group}_{row.galaxy}.*' else: imgfile = f'img_*_{row.galaxy}.*' image = glob.glob(f"{imgpath.absolute()}/{imgfile}") if len(image)>0: df.loc[i, 'filename'] = image[0] not_found = sum(df['filename']=='') if not_found >0: print(f'\nWARNING: {not_found} images where not found. Check if the provided path is correct. Or download the images using the provided tool.') else: print('Done!') return df Loading @@ -144,7 +162,7 @@ def createInputFile(imgpath:str, fname:str) -> pd.DataFrame: print(f'INFO:\tCreating {fname} file... ', end='', flush=True) df = pd.DataFrame(columns=INPUTCOLUMNS) if imgpath: for file in Path(imgpath).glob('img_*_*.png'): for file in Path(imgpath).glob('img_*_*.*'): entry = { 'group': int(file.stem.split('_')[1]), 'galaxy': int(file.stem.split('_')[2]), Loading @@ -154,11 +172,11 @@ def createInputFile(imgpath:str, fname:str) -> pd.DataFrame: } df = pd_concat(df, entry) #groups = groups.append(entry, ignore_index=True) # sort # if groups not defined if sum(df["groups"] == '-') == len(df): df.drop("groups", axis=1, inplace=True) INPUTCOLUMNS.remove("groups") # sort sortby=[] if 'galaxy' in df.columns: sortby.insert(0, 'galaxy') Loading