nFette[0] = 0
        if patientdir[-1]=='/':
            patID = patientdir.split('/')[-2].replace('.','')
        else:
            patID = patientdir.split('/')[-1].replace('.','')
        patientID[:63] = patID
        print("working on patient: "+patientID)
        print("in the directory: "+pathT2)
        if os.path.isdir(pathT2):
            print("T2 dir found.")
        pathROI = analasisysdir + "ROI/"
        if os.path.isdir(pathROI):
            print("ROI dir found.")

        infos = info_file_parser(analasisysdir + "info.txt")
        timeflag[0] = timeflagconverter_string2int(infos["time"])
        ypT[0] = int(infos["ypT"])
        
        #         # data, ROI = read_files(pathT2, pathROI, args.verbose, True)
        freader = FileReader(pathT2, pathROI, args.verbose)
        try:
            data, ROI = freader.read(raw=True)
        except NotImplementedError:
            data = freader.readUsingGDCM(raw=True)
            ROI = freader.readROI()
        except ValueError:
            continue
        
        roinorm=False
        
Example #2
0
        
        nFette = 0
        if patientdir[-1]=='/':
            patID = patientdir.split('/')[-2].replace('.','')
        else:
            patID = patientdir.split('/')[-1].replace('.','')
        patientID = patID
        print("working on patient: "+patientID)
        print("in the directory: "+pathT2)
        if os.path.isdir(pathT2):
            print("T2 dir found.")
        pathROI = analasisysdir + "ROI/"
        if os.path.isdir(pathROI):
            print("ROI dir found.")

        infos = info_file_parser(analasisysdir + "info2.txt")
        timeflag = timeflagconverter_string2int(infos["time"])
        ypT = int(infos["ypT"])
        ypT2 = int(infos["ypT2"])
        
        #         # data, ROI = read_files(pathT2, pathROI, args.verbose, True)
        freader = FileReader(pathT2, pathROI, args.verbose)
        try:
            data, ROI = freader.read(raw=True)
        except NotImplementedError:
            data = freader.readUsingGDCM(raw=True)
            ROI = freader.readROI()
        except ValueError:
            print("Data not read. Check folders")
            continue
    
Example #3
0
def check_dir(inputdir, verbose=False):
    if verbose:
        print("inputdir", inputdir)
    table = []

    patientdirs = glob.glob(inputdir + "*/")
    for patientdir in patientdirs:

        if verbose:
            print(patientdir)
        if patientdir[-1] == '/':
            patID = patientdir.split('/')[-2].replace('.', '')
        else:
            patID = patientdir.split('/')[-1].replace('.', '')
        if verbose:
            print("id:", patID)

        analasisysdirs = glob.glob(patientdir + "*/")
        for analasisysdir in analasisysdirs:
            patient = []
            patient.append(patID)

            if verbose:
                print("\t", analasisysdir)

            pathT2 = analasisysdir + "T2/"
            pathROI = analasisysdir + "ROI/"
            # freader = FileReader(pathT2, pathROI, args.verbose)
            if verbose:
                print("reading on patient: " + patID)
                print("T2 directory: " + pathT2)
            if os.path.isdir(pathT2):
                dicomfiles = glob.glob(pathT2 + "/*.dcm")
                allfiles = glob.glob(pathT2 + "/*")
                patient.append(len(dicomfiles))
                patient.append(len(allfiles) - len(dicomfiles))
            else:
                patient.append(0)
                patient.append(0)

            pathROI = analasisysdir + "ROI/"
            if os.path.isdir(pathROI):
                nrrdfiles = glob.glob(pathROI + "/*.nrrd")
                if len(nrrdfiles) > 0:
                    fr = nrrdFileHandler(False)
                    nrrdROI = fr.read(nrrdfiles[0])
                    dicomfiles = glob.glob(pathROI + "/*.dcm")
                    allfiles = glob.glob(pathROI + "/*")
                    # patient.append(len(nrrdfiles))
                    patient.append(len(nrrdROI))
                    patient.append(len(dicomfiles))
                    patient.append(
                        len(allfiles) - len(dicomfiles) - len(nrrdfiles))
                else:
                    patient.append(0)
                    patient.append(0)
                    patient.append(0)
            else:
                patient.append(0)
                patient.append(0)
                patient.append(0)

            infofilename = analasisysdir + "info.txt"
            if os.path.isfile(infofilename):
                infos = info_file_parser(infofilename)
                patient.append(infos["time"])
                patient.append(infos["ypT"])
                patient.append(infos["name"])

            else:
                patient.append("None")
                patient.append("None")
                patient.append("None")

            table.append(patient)
    return table
Example #4
0
def check_dir(inputdir, verbose=False):
    if verbose:
        print("inputdir",inputdir)
    table = []

    patientdirs= glob.glob(inputdir+"*/")
    for patientdir in patientdirs:

        
        if verbose:
            print(patientdir)
        if patientdir[-1]=='/':
            patID = patientdir.split('/')[-2].replace('.','')
        else:
            patID = patientdir.split('/')[-1].replace('.','')
        if verbose:
            print("id:",patID)

        analasisysdirs=glob.glob(patientdir+"*/")
        for analasisysdir in analasisysdirs:
            patient = []
            patient.append(patID)
            
            if verbose:
                print("\t",analasisysdir)

            pathT2 = analasisysdir + "T2/"
            pathROI = analasisysdir + "ROI/"
                # freader = FileReader(pathT2, pathROI, args.verbose)
            if verbose:
                print("reading on patient: "+patID)
                print("T2 directory: "+pathT2)
            if os.path.isdir(pathT2):
                dicomfiles = glob.glob(pathT2+"/*.dcm")
                allfiles = glob.glob(pathT2+"/*")
                patient.append(len(dicomfiles))
                patient.append(len(allfiles)-len(dicomfiles))                
            else:
                patient.append(0)
                patient.append(0)                
            
            pathROI = analasisysdir + "ROI/"
            if os.path.isdir(pathROI):
                nrrdfiles = glob.glob(pathROI+"/*.nrrd")
                if len(nrrdfiles) > 0 :
                    fr = nrrdFileHandler(False)
                    nrrdROI = fr.read(nrrdfiles[0])
                    dicomfiles = glob.glob(pathROI+"/*.dcm")
                    allfiles = glob.glob(pathROI+"/*")
                    # patient.append(len(nrrdfiles))
                    patient.append(len(nrrdROI))
                    patient.append(len(dicomfiles))
                    patient.append(len(allfiles)-len(dicomfiles)-len(nrrdfiles))
                else:
                    patient.append(0)
                    patient.append(0)
                    patient.append(0)
            else:
                patient.append(0)
                patient.append(0)
                patient.append(0)

            infofilename = analasisysdir + "info.txt"
            if os.path.isfile(infofilename):
                infos = info_file_parser(infofilename)
                patient.append(infos["time"])
                patient.append(infos["ypT"])                         
                patient.append(infos["name"])

            else:
                patient.append("None")
                patient.append("None")                         
                patient.append("None")


            table.append(patient)
    return table