Esempio n. 1
0
 def _associationRules(self, LITables):
     associationRules = []
     # start from L2
     for LITable in LITables[1:]:
         for tIdx, trans in enumerate(LITable.eventRows):
             cTrans = LITable.countList[tIdx]
             for cutPoint in range(1, LITable.level):
                 candiRule = Rule()
                 for idx in range(cutPoint):
                     candiRule.IF.append(trans[idx])
                 for idx in range(cutPoint, LITable.level):
                     candiRule.THEN.append(trans[idx])
                 iftIdx = Tools.listInListSet(
                     candiRule.IF, LITables[cutPoint - 1].eventRows)
                 cCondi = LITables[cutPoint - 1].countList[iftIdx]
                 candiRule.conf = round(cTrans / cCondi, 3)
                 if candiRule.conf > self.minConf:
                     candiRule.sup = round(cTrans / self._transNum, 3)
                     rlen = LITable.level - cutPoint - 1
                     thtIdx = Tools.listInListSet(candiRule.THEN,
                                                  LITables[rlen].eventRows)
                     cResult = LITables[rlen].countList[thtIdx]
                     candiRule.lift = round(
                         (cTrans * self._transNum) / (cCondi * cResult), 3)
                     associationRules.append(candiRule)
     return associationRules
Esempio n. 2
0
 def _largeItemSets(self, subSeriesSet):
     LargeItemTables = []
     # build L1
     msg = '\nstart, level=1 ...\n'
     self._manegeMsg(msg)
     La = LargeItemTable(1)
     for subSeries in subSeriesSet:
         for event in subSeries:
             eventRow = [event]
             pos = Tools.listInListSet(eventRow, La.eventRows)
             if pos == -1:
                 La.add(eventRow, 1)
             else:
                 La.countList[pos] += 1
     La.reduce(self._scalarMinSup)
     if (len(La) <= 0):
         return LargeItemTables
     LargeItemTables.append(La)
     lvCount = 2
     Lb = LargeItemTable(2)
     # L2 to Ln until convergence
     while (True):
         msg = '\nstart, level=' + str(lvCount) + ' ...\n'
         self._manegeMsg(msg)
         # A: build Lb from La
         len_ = len(La.eventRows)
         for idx1 in range(len_ - 1):
             for idx2 in range(idx1 + 1, len_):
                 newRow = self._mergeTrans(lvCount - 1, La.eventRows,
                                           La.eventRows[idx1],
                                           La.eventRows[idx2])
                 if newRow is not None:
                     Lb.add(newRow, 0)
         # B: if Lb is empty, terminal condition is statisfied
         if (len(Lb) <= 0):
             return LargeItemTables
         LargeItemTables.append(Lb)
         # C: count Lb from subSeriesSet
         for eIdx, eventRow in enumerate(Lb.eventRows):
             count = 0
             for subSeries in subSeriesSet:
                 if Tools.isSubSet(eventRow, subSeries):
                     count += 1
             Lb.countList[eIdx] = count
         # D: remove eventRow of which count does not reach min support
         Lb.reduce(self._scalarMinSup)
         # E: prepare for next round
         La = Lb
         lvCount += 1
         Lb = LargeItemTable(lvCount)
Esempio n. 3
0
 def resize_image(image, path, new_size=None, count=0):
     """Resize an image using PIL"""
     from PIL import Image
     if count == 3:
         mode = 0
     else:
         mode = 1
     # original_height, original_width = image.size
     # factor = int(new_size/original_width)
     # new_width = int(original_width * factor)
     # new_height = int(original_height * factor)
     resized_image_arr = Tools.opencv_resize(path, new_size, new_size, mode=mode)
     resized_image = Image.fromarray(resized_image_arr)
     # new_image = PIL.Image.fromarray(resized_image)
     # resized_imgage = image.resize((new_width, new_height), Image.ANTIALIAS)
     return resized_image
Esempio n. 4
0
 def _mergeTrans(self, n, Ln, transA, transB):
     n -= 1
     for idx in range(n):
         if transA[idx] != transB[idx]:
             return None
     if transA[n].samePoint(transB[n]):
         return None
     if (transB[n].timePoint - transA[n].timePoint) >= self.maxGap:
         return None
     if transA[n] < transB[n]:
         # generate new candidate
         trans = copy.deepcopy(transA)
         trans.append(transB[n])
         # check all subsets are in Ln
         for idx in range(n + 1):
             subset = copy.deepcopy(trans)
             del subset[idx]
             if Tools.listInListSet(subset, Ln) == -1:
                 return None
         return trans
     return None
Esempio n. 5
0
    def add_moving_image(self):
        """Open an image file and show it in the GUI"""
        from PIL import Image
        self.png_dest_2 = MY_PNG_DEST_2
        try:
            # Searching file
            self.im_moving_path = askopenfilename(
                initialdir=".",
                filetypes=(("Dicom (*.DCM)", "*.dcm"),
                           ("JPEG (*.JPG)", "*.jpg*"), ("PNG (*.PNG)",
                                                        "*.png*")),
                title="Choose image 2.")
            # Converting .dcm file to .png for manipulation
            if self.im_moving_path[-3:] == 'dcm':
                convert = Tools.Convert()
                convert.dicom_to_png(self.im_moving_path, self.png_dest_2)
                dicom_info = convert.dicom_file_info
                self.label_dicom_data_2.configure(text=dicom_info)
                self.png_path_list[1] = self.png_dest_2
            else:
                self.png_dest_2 = self.im_moving_path
                self.png_path_list[1] = self.im_moving_path
                self.label_dicom_data_2.configure(text="None")

            # resize and place it in the Frame
            self.png_moving_img = Image.open(self.png_dest_2)
            self.png_moving_img.thumbnail(IN_SIZE, Image.ANTIALIAS)

            self.moving_object = Zoom.ZoomAdvanced(self.frame_moving,
                                                   self.png_moving_img)

            self.im_moving_path = self.png_dest_2

            self.scale_br_moving.set(1)

        except:
            pass
Esempio n. 6
0
    def __init__(self, top=None):
        """This class configures and populates the toplevel window.
                top is the toplevel containing window."""

        # Loading required assets and paths. Initializing variables
        self.icon_path = Tools.resource_path(MY_ICON)
        self.see_btn_path = Tools.resource_path(MY_SEE_BTN_PATH)
        self.save_btn_path = Tools.resource_path(MY_SAVE_BTN_PATH)
        self.delete_btn_path = Tools.resource_path(MY_DELETE_BTN_PATH)
        self.empty_image_path = Tools.resource_path(MY_EMPTY_IMAGE_PATH)
        self.png_dest_1 = MY_PNG_DEST_1
        self.png_dest_2 = MY_PNG_DEST_2
        self.im_fixed_path = None
        self.im_moving_path = None
        self.png_fixed_img = None
        self.png_moving_img = None
        self.output_image = None
        self.fixed_object = None
        self.moving_object = None
        self.reg_object = None
        self.bw_object = None
        self.bw_image = None
        self.radio_var = IntVar()
        self.png_path_list = [
            self.png_dest_1, self.png_dest_2, MY_OUT_DEST, MY_OUT_DEST
        ]

        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'
        font9 = "-family Verdana -size 9 -weight normal -slant roman" \
                 " -underline 0 -overstrike 0"
        font11 = "-family Verdana -size 11 -weight normal -slant roman"  \
            " -underline 0 -overstrike 0"
        font13 = "-family Verdana -size 13 -weight normal -slant roman "  \
            "-underline 0 -overstrike 0"

        # Creating all the GUI
        top.geometry("1200x650+127+8")
        top.title("Regim")
        top.iconbitmap(self.icon_path)
        top.resizable(False, False)
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#ffffff")
        top.configure(highlightcolor="black")

        # Menu bar configuration
        self.menubar = Menu(top, font="TkMenuFont")
        top.configure(menu=self.menubar)

        self.file = Menu(top, tearoff=0)
        self.menubar.add_cascade(menu=self.file,
                                 font="TkMenuFont",
                                 label="File")
        self.file.add_command(font="TkMenuFont",
                              label="Exit",
                              command=exit_btn)

        self.help = Menu(top, tearoff=0)

        self.menubar.add_cascade(menu=self.help,
                                 font="TkMenuFont",
                                 foreground="#000000",
                                 label="Help")
        self.help.add_command(font="TkMenuFont",
                              foreground="#000000",
                              label="About",
                              command=self.open_browser)

        # Frames configuration
        self.frame_side = Frame(top)
        self.frame_side.place(relx=-0.02,
                              rely=-0.02,
                              relheight=1.01,
                              relwidth=0.16)
        self.frame_side.configure(relief=SUNKEN)
        self.frame_side.configure(borderwidth="1")
        self.frame_side.configure(relief=SUNKEN)
        self.frame_side.configure(background="#202020")  # color #383838
        self.frame_side.configure(highlightbackground="#ffffff")
        self.frame_side.configure(highlightcolor="black")
        self.frame_side.configure(width=215)

        # Registration button
        self.reg_button = Button(self.frame_side)
        self.reg_button.place(relx=0.16, rely=0.87, height=34, width=150)
        self.reg_button.configure(activebackground="#0f306a")
        self.reg_button.configure(activeforeground="white")
        self.reg_button.configure(activeforeground="#ffffff")
        self.reg_button.configure(background=BASIC_COLOR)
        self.reg_button.configure(borderwidth="0")
        self.reg_button.configure(disabledforeground="#a3a3a3")
        self.reg_button.configure(font=font13)
        self.reg_button.configure(foreground="#ffffff")
        self.reg_button.configure(highlightbackground="#d9d9d9")
        self.reg_button.configure(highlightcolor="black")
        self.reg_button.configure(overrelief="sunken")
        self.reg_button.configure(pady="0")
        self.reg_button.configure(relief=FLAT)
        self.reg_button.configure(text='Registration')
        self.reg_button.configure(cursor="hand2")
        self.reg_button.configure(command=self.do_registration)

        # Side menu
        self.label_side = LabelFrame(self.frame_side)
        self.label_side.place(relx=0.16,
                              rely=0.085,
                              relheight=0.755,
                              relwidth=0.8)
        self.label_side.configure(borderwidth="1")
        self.label_side.configure(foreground="black")
        self.label_side.configure(relief=FLAT)
        self.label_side.configure(background="#393939")  # color #585858
        self.label_side.configure(width=150)

        # Frame inputs and output
        self.frame_process = Frame(top)
        self.frame_process.place(relx=0.137,
                                 rely=0.02,
                                 relheight=1.02,
                                 relwidth=0.883)
        self.frame_process.configure(borderwidth="1")
        self.frame_process.configure(background="#5d5f60")
        self.frame_process.configure(highlightbackground="#000000")
        self.frame_process.configure(highlightcolor="#ffffff")
        self.frame_process.configure(width=805)

        # Frame DICOM info 1
        self.frame_dicom_info_1 = Frame(self.frame_process)
        self.frame_dicom_info_1.place(relx=0.28,
                                      rely=0.08,
                                      height=200,
                                      width=140)
        self.frame_dicom_info_1.configure(borderwidth="0")
        self.frame_dicom_info_1.configure(background="#ccc")
        self.frame_dicom_info_1.configure(highlightbackground="#000000")
        self.frame_dicom_info_1.configure(highlightcolor="#ffffff")

        # Frame DICOM info 2
        self.frame_dicom_info_2 = Frame(self.frame_process)
        self.frame_dicom_info_2.place(relx=0.28,
                                      rely=0.51,
                                      height=200,
                                      width=140)
        self.frame_dicom_info_2.configure(borderwidth="0")
        self.frame_dicom_info_2.configure(background="#ccc")
        self.frame_dicom_info_2.configure(highlightbackground="#000000")
        self.frame_dicom_info_2.configure(highlightcolor="#ffffff")

        # Frame Outputs
        self.frame_outputs = Frame(self.frame_process)
        self.frame_outputs.place(relx=0.47, rely=0, relheight=1.02)
        self.frame_outputs.configure(borderwidth="0")
        self.frame_outputs.configure(background="#444749")
        self.frame_outputs.configure(highlightbackground="#000000")
        self.frame_outputs.configure(highlightcolor="#ffffff")
        self.frame_outputs.configure(width=564)

        # Registered image frame
        self.frame_registered = Frame(self.frame_outputs)
        self.frame_registered.place(relx=0.11,
                                    rely=0.08,
                                    height=202,
                                    width=202)
        self.frame_registered.configure(borderwidth="0")
        self.frame_registered.configure(background="#ccc")
        self.frame_registered.configure(highlightbackground="#000000")
        self.frame_registered.configure(highlightcolor="#ffffff")

        # Registered B&W image frame
        self.frame_bw = Frame(self.frame_outputs)
        self.frame_bw.place(relx=0.11, rely=0.498, height=202, width=202)
        self.frame_bw.configure(borderwidth="0")
        self.frame_bw.configure(background="#ccc")
        self.frame_bw.configure(highlightbackground="#000000")
        self.frame_bw.configure(highlightcolor="#ffffff")

        # Data frame
        self.frame_data = Frame(self.frame_outputs)
        self.frame_data.place(relx=0.59, rely=0.08, height=202, width=122)
        self.frame_data.configure(borderwidth="0")
        self.frame_data.configure(background="#ccc")
        self.frame_data.configure(highlightbackground="#000000")
        self.frame_data.configure(highlightcolor="#ffffff")

        # Right frame
        self.frame_right = Frame(self.frame_process)
        self.frame_right.place(relx=0.946, rely=0, relheight=1.02)
        self.frame_right.configure(borderwidth="0")
        self.frame_right.configure(background="#1d1f21")
        self.frame_right.configure(highlightbackground="#000000")
        self.frame_right.configure(highlightcolor="#ffffff")
        self.frame_right.configure(width=40)

        # Frame slider 1
        self.frame_slider_1 = Frame(self.frame_process)
        self.frame_slider_1.place(relx=0.05, rely=0.41, height=17, width=200)
        self.frame_slider_1.configure(borderwidth="0")
        self.frame_slider_1.configure(background="#000")
        self.frame_slider_1.configure(highlightbackground="#000000")
        self.frame_slider_1.configure(highlightcolor="#ffffff")

        # Brightness slider 1
        self.scale_br_fixed = Scale(self.frame_slider_1,
                                    from_=0,
                                    to=4,
                                    orient=HORIZONTAL,
                                    resolution=0.2)
        self.scale_br_fixed.place(relx=0.0, rely=-1.2, width=200)
        self.scale_br_fixed.configure(background="#393939")
        self.scale_br_fixed.configure(activebackground="#202020")
        self.scale_br_fixed.configure(borderwidth="0")
        self.scale_br_fixed.configure(command=lambda _: self.enhance_image(
            self.fixed_object, self.png_fixed_img, self.scale_br_fixed, None))
        self.scale_br_fixed.set(1)

        # Frame slider 2
        self.frame_slider_2 = Frame(self.frame_process)
        self.frame_slider_2.place(relx=0.05, rely=0.84, height=17, width=200)
        self.frame_slider_2.configure(borderwidth="0")
        self.frame_slider_2.configure(background="#000")
        self.frame_slider_2.configure(highlightbackground="#000000")
        self.frame_slider_2.configure(highlightcolor="#ffffff")

        # Brightness slider 2
        self.scale_br_moving = Scale(self.frame_slider_2,
                                     from_=0,
                                     to=4,
                                     orient=HORIZONTAL,
                                     resolution=0.2)
        self.scale_br_moving.place(relx=0.0, rely=-1.2, width=200)
        self.scale_br_moving.configure(background="#393939")
        self.scale_br_moving.configure(activebackground="#202020")
        self.scale_br_moving.configure(borderwidth="0")
        self.scale_br_moving.configure(command=lambda _: self.enhance_image(
            self.moving_object, self.png_moving_img, self.scale_br_moving, None
        ))
        self.scale_br_moving.set(1)

        # Frame slider 3
        self.frame_slider_3 = Frame(self.frame_outputs)
        self.frame_slider_3.place(relx=0.11, rely=0.826, height=17, width=200)
        self.frame_slider_3.configure(borderwidth="0")
        self.frame_slider_3.configure(background="#000")
        self.frame_slider_3.configure(highlightbackground="#000000")
        self.frame_slider_3.configure(highlightcolor="#ffffff")

        # Brightness slider 3
        self.scale_br_bw = Scale(self.frame_slider_3,
                                 from_=0,
                                 to=4,
                                 orient=HORIZONTAL,
                                 resolution=0.2)
        self.scale_br_bw.place(relx=0.0, rely=-1.2, width=200)
        self.scale_br_bw.configure(background="#393939")
        self.scale_br_bw.configure(activebackground="#202020")
        self.scale_br_bw.configure(borderwidth="0")
        self.scale_br_bw.configure(command=lambda _: self.enhance_image(
            self.bw_object, self.bw_image, self.scale_br_bw, None))
        self.scale_br_bw.set(1)

        # Frame slider 4
        self.frame_slider_4 = Frame(self.frame_outputs)
        self.frame_slider_4.place(relx=0.11, rely=0.405, height=17, width=200)
        self.frame_slider_4.configure(borderwidth="0")
        self.frame_slider_4.configure(background="#000")
        self.frame_slider_4.configure(highlightbackground="#000000")
        self.frame_slider_4.configure(highlightcolor="#ffffff")

        # Brightness slider 4
        self.scale_br_registered = Scale(self.frame_slider_4,
                                         from_=0,
                                         to=4,
                                         orient=HORIZONTAL,
                                         resolution=0.2)
        self.scale_br_registered.place(relx=0.0, rely=-1.2, width=200)
        self.scale_br_registered.configure(background="#393939")
        self.scale_br_registered.configure(activebackground="#202020")
        self.scale_br_registered.configure(borderwidth="0")
        self.scale_br_registered.configure(
            command=lambda _: self.enhance_image(
                self.reg_object, self.output_image, self.scale_br_registered,
                None))
        self.scale_br_registered.set(1)

        # Frame fixed image
        self.frame_fixed = Frame(self.frame_process)
        self.frame_fixed.place(relx=0.05, rely=0.08, height=200, width=200)
        self.frame_fixed.configure(borderwidth="1")
        self.frame_fixed.configure(background=BASIC_COLOR)  # color #383838
        self.frame_fixed.configure(cursor="fleur")

        # Frame moving image
        self.frame_moving = Frame(self.frame_process)
        self.frame_moving.place(relx=0.05, rely=0.51, height=200, width=200)
        self.frame_moving.configure(borderwidth="1")
        self.frame_moving.configure(background=BASIC_COLOR)  # color #383838
        self.frame_moving.configure(cursor="fleur")

        # Frame inner bw image
        self.frame_bw_editable = Frame(self.frame_bw)
        self.frame_bw_editable.place(relx=0.003,
                                     rely=0.003,
                                     height=200,
                                     width=200)
        self.frame_bw_editable.configure(borderwidth="0")
        self.frame_bw_editable.configure(background="#444749")  # color #383838
        self.frame_bw_editable.configure(cursor="fleur")

        # Frame inner registered image
        self.frame_registered_editable = Frame(self.frame_registered)
        self.frame_registered_editable.place(relx=0.003,
                                             rely=0.003,
                                             height=200,
                                             width=200)
        self.frame_registered_editable.configure(borderwidth="0")
        self.frame_registered_editable.configure(
            background="#444749")  # color #383838
        self.frame_registered_editable.configure(cursor="fleur")

        # Data label
        self.label_data = Label(self.frame_data)
        self.label_data.place(relx=0.005, rely=0.003, height=30, width=120)
        self.label_data.configure(background="#444749")
        self.label_data.configure(cursor="")
        self.label_data.configure(font=font9)
        self.label_data.configure(foreground="#ccc")
        self.label_data.configure(text='Data')

        # Info label
        self.label_info = Label(self.frame_data)
        self.label_info.place(relx=0.005, rely=0.155, height=170, width=120)
        self.label_info.configure(background="#444749")
        self.label_info.configure(cursor="")
        self.label_info.configure(font=font9)
        self.label_info.configure(foreground="#ccc")
        self.label_info.configure(wraplength=100)

        # Title DICOM info 1
        self.label_title_1 = Label(self.frame_dicom_info_1)
        self.label_title_1.place(relx=0.005, rely=0.003, height=30, width=138)
        self.label_title_1.configure(background="#5d5f60")
        self.label_title_1.configure(cursor="")
        self.label_title_1.configure(font=font9)
        self.label_title_1.configure(foreground="#ccc")
        self.label_title_1.configure(text='DICOM info')

        # Label DICOM data 1
        self.label_dicom_data_1 = Label(self.frame_dicom_info_1)
        self.label_dicom_data_1.place(relx=0.005,
                                      rely=0.145,
                                      height=170,
                                      width=138)
        self.label_dicom_data_1.configure(background="#5d5f60")
        self.label_dicom_data_1.configure(cursor="")
        self.label_dicom_data_1.configure(font=font9)
        self.label_dicom_data_1.configure(foreground="#ccc")
        self.label_dicom_data_1.configure(text='')
        self.label_dicom_data_1.configure(wraplength=120)

        # Title DICOM info 2
        self.label_title_2 = Label(self.frame_dicom_info_2)
        self.label_title_2.place(relx=0.005, rely=0.003, height=30, width=138)
        self.label_title_2.configure(background="#5d5f60")
        self.label_title_2.configure(cursor="")
        self.label_title_2.configure(font=font9)
        self.label_title_2.configure(foreground="#ccc")
        self.label_title_2.configure(text='DICOM info')

        # Label DICOM data 2
        self.label_dicom_data_2 = Label(self.frame_dicom_info_2)
        self.label_dicom_data_2.place(relx=0.005,
                                      rely=0.145,
                                      height=170,
                                      width=138)
        self.label_dicom_data_2.configure(background="#5d5f60")
        self.label_dicom_data_2.configure(cursor="")
        self.label_dicom_data_2.configure(font=font9)
        self.label_dicom_data_2.configure(foreground="#ccc")
        self.label_dicom_data_2.configure(text='')
        self.label_dicom_data_2.configure(wraplength=120)

        # Frame foot
        self.frame_foot = Frame(top)
        self.frame_foot.place(relx=-0.01,
                              rely=0.94,
                              relheight=0.07,
                              relwidth=1.02)
        self.frame_foot.configure(relief=SUNKEN)
        self.frame_foot.configure(borderwidth="1")
        self.frame_foot.configure(relief=SUNKEN)
        self.frame_foot.configure(background="#202020")  # color #383838
        self.frame_foot.configure(highlightbackground="#d9d9d9")
        self.frame_foot.configure(highlightcolor="#ffffff")
        self.frame_foot.configure(width=995)

        # Top frame
        self.frame_top = Frame(top)
        self.frame_top.place(relx=-0.01,
                             rely=-0.1,
                             relheight=0.14,
                             relwidth=1.03)
        self.frame_top.configure(relief=RIDGE)
        self.frame_top.configure(borderwidth="1")
        self.frame_top.configure(relief=RIDGE)
        self.frame_top.configure(background="#202020")
        self.frame_top.configure(highlightbackground="#d9d9d9")
        self.frame_top.configure(highlightcolor="#ffffff")
        self.frame_top.configure(width=1005)

        # SEE button
        self.see_button = Button(self.frame_right)
        self.see_button.place(relx=0.05, rely=0.05, height=30, width=30)
        self.see_button.configure(activebackground="#1d1f21")
        self.see_button.configure(background="#d9d9d9")
        self.see_button.configure(borderwidth="0")
        self.see_button.configure(cursor="hand2")
        self._see_img = PhotoImage(file=self.see_btn_path)
        self.see_button.configure(image=self._see_img)
        self.see_button.configure(command=self.open_visualizer)

        # SAVE AS button
        self.save_button = Button(self.frame_right)
        self.save_button.place(relx=0.05, rely=0.73, height=30, width=30)
        self.save_button.configure(activebackground="#fff")
        self.save_button.configure(background="#d9d9d9")
        self.save_button.configure(borderwidth="0")
        self.save_button.configure(cursor="hand2")
        self._save_img = PhotoImage(file=self.save_btn_path)
        self.save_button.configure(image=self._save_img)
        self.save_button.configure(command=self.save_file)

        # DELETE button
        self.delete_button = Button(self.frame_right)
        self.delete_button.place(relx=0.05, rely=0.82, height=30, width=30)
        self.delete_button.configure(activebackground="#fff")
        self.delete_button.configure(background="#d9d9d9")
        self.delete_button.configure(borderwidth="0")
        self.delete_button.configure(cursor="hand2")
        self._del_img = PhotoImage(file=self.delete_btn_path)
        self.delete_button.configure(image=self._del_img)
        self.delete_button.configure(command=self.delete_files)

        # Left menu labels
        self.select_input_label = Label(self.label_side)
        self.select_input_label.place(relx=0, rely=0, height=30, width=150)
        self.select_input_label.configure(background=BASIC_COLOR)
        self.select_input_label.configure(foreground="#fff")
        self.select_input_label.configure(font=font11)
        self.select_input_label.configure(text="Select inputs")
        # Select fixed image button
        self.select_fixed_btn = Button(self.label_side)
        self.select_fixed_btn.place(relx=0, rely=0.08, height=26, width=150)
        self.select_fixed_btn.configure(background="#393939")
        self.select_fixed_btn.configure(activebackground="#474747")
        self.select_fixed_btn.configure(activeforeground="#cccccc")
        self.select_fixed_btn.configure(foreground="#ccc")
        self.select_fixed_btn.configure(font=font11)
        self.select_fixed_btn.configure(text="Fixed image")
        self.select_fixed_btn.configure(borderwidth="0")
        self.select_fixed_btn.configure(cursor="hand2")
        self.select_fixed_btn.configure(command=self.add_fixed_image)
        # Select moving image button
        self.select_moving_btn = Button(self.label_side)
        self.select_moving_btn.place(relx=0, rely=0.15, height=26, width=150)
        self.select_moving_btn.configure(background="#393939")
        self.select_moving_btn.configure(activebackground="#474747")
        self.select_moving_btn.configure(activeforeground="#cccccc")
        self.select_moving_btn.configure(foreground="#ccc")
        self.select_moving_btn.configure(font=font11)
        self.select_moving_btn.configure(text="Moving image")
        self.select_moving_btn.configure(borderwidth="0")
        self.select_moving_btn.configure(cursor="hand2")
        self.select_moving_btn.configure(command=self.add_moving_image)
        # Left method label
        self.select_method_label = Label(self.label_side)
        self.select_method_label.place(relx=0, rely=0.23, height=30, width=150)
        self.select_method_label.configure(background=BASIC_COLOR)
        self.select_method_label.configure(foreground="#fff")
        self.select_method_label.configure(font=font11)
        self.select_method_label.configure(text="Regim methods")
        # Select displacement method button
        self.select_disp_btn = Radiobutton(self.label_side,
                                           variable=self.radio_var,
                                           value=1)
        self.select_disp_btn.place(relx=0, rely=0.294, height=38, width=150)
        self.select_disp_btn.configure(selectcolor='#515151',
                                       indicatoron=False)
        self.select_disp_btn.configure(background="#393939")
        self.select_disp_btn.configure(foreground="#ccc")
        self.select_disp_btn.configure(activebackground="#474747")
        self.select_disp_btn.configure(activeforeground="#ccc")
        self.select_disp_btn.configure(font=font11)
        self.select_disp_btn.configure(text="Displacement")
        self.select_disp_btn.configure(borderwidth="0")
        self.select_disp_btn.configure(cursor="hand2")
        self.select_disp_btn.select()
        # Select restrictive method button
        self.select_restrc_btn = Radiobutton(self.label_side,
                                             variable=self.radio_var,
                                             value=2)
        self.select_restrc_btn.place(relx=0, rely=0.37, height=38, width=150)
        self.select_restrc_btn.configure(selectcolor='#515151',
                                         indicatoron=False)
        self.select_restrc_btn.configure(background="#393939")
        self.select_restrc_btn.configure(foreground="#ccc")
        self.select_restrc_btn.configure(activebackground="#474747")
        self.select_restrc_btn.configure(activeforeground="#ccc")
        self.select_restrc_btn.configure(font=font11)
        self.select_restrc_btn.configure(text="Restrictive")
        self.select_restrc_btn.configure(borderwidth="0")
        self.select_restrc_btn.configure(cursor="hand2")
        # Left parameters label
        self.select_parameters_label = Label(self.label_side)
        self.select_parameters_label.place(relx=0,
                                           rely=0.45,
                                           height=30,
                                           width=150)
        self.select_parameters_label.configure(background=BASIC_COLOR)
        self.select_parameters_label.configure(foreground="#fff")
        self.select_parameters_label.configure(font=font11)
        self.select_parameters_label.configure(text="Parameters")
        # Iterations label
        self.iterations_input = Label(self.label_side)
        self.iterations_input.place(relx=0, rely=0.53, height=26, width=150)
        self.iterations_input.configure(background="#393939")
        self.iterations_input.configure(foreground="#ccc")
        self.iterations_input.configure(activebackground="#474747")
        self.iterations_input.configure(activeforeground="#cccccc")
        self.iterations_input.configure(font=font11)
        self.iterations_input.configure(text="Iterations")
        self.iterations_input.configure(borderwidth="0")
        # Max iterations entry
        self.iterations_entry = Entry(self.label_side)
        self.iterations_entry.place(relx=0.28, rely=0.61, height=17, width=60)
        self.iterations_entry.configure(background="#ccc")
        self.iterations_entry.configure(disabledforeground="#a3a3a3")
        self.iterations_entry.configure(foreground="#000")
        self.iterations_entry.configure(font=font11)
        self.iterations_entry.configure(borderwidth="0")
        self.iterations_entry.insert(0, "100")

        # Progress bar
        s = ttk.Style()
        s.theme_use('clam')
        s.configure("red.Horizontal.TProgressbar",
                    troughcolor='#202020',
                    background=BASIC_COLOR)
        self.progress_bar = ttk.Progressbar(
            self.frame_foot,
            style="red.Horizontal.TProgressbar",
            orient='horizontal',
            mode='determinate')
        self.progress_bar.place(relx=0, rely=0, height=40, width=1215)
        self.mask = Label(self.frame_foot)
        self.mask.place(relx=0, rely=0, height=31, width=1215)
        self.mask.configure(background='#202020')

        # Success bar
        ss = ttk.Style()
        ss.theme_use('clam')
        ss.configure("blue.Horizontal.TProgressbar",
                     troughcolor='#202020',
                     background=BASIC_COLOR)
        self.success_bar = ttk.Progressbar(
            self.frame_data,
            style="blue.Horizontal.TProgressbar",
            orient='horizontal',
            mode='determinate')
        self.success_bar.place(relx=0.1, rely=0.8, height=20, width=100)
Esempio n. 7
0
    stockName = os.path.splitext(file)[0]
    eventSeries.extend(EventFactory.extractEvent(stockName, saxSeries, False))

    print('-- Stock Series: \'' + stockName + '\' loaded.')

    # stocks number constrainer
    if(count == 1):
        break
    else:
        count -= 1

# make series in order
eventSeries.sort()

print()
print('searching ...')

# start mining with apriori
assocRules = apriori.analyze(eventSeries)

# show result
outTxt = apriori.getMessage() + '\n' + Tools.beautifiedRuleSet(assocRules)
print(outTxt)

if not os.path.exists(outputDir):
    os.makedirs(outputDir)

with open(outputDir / 'result.txt', 'w') as rFile:
    rFile.write(outTxt)