roinorm = myroi2roi(myroisnorm, data.shape, args.verbose) if args.verbose: print("norm file read") if args.verbose: print("data mean:",data.mean(),"min:",data.min(),"max:",data.max(),"shape:",data.shape) print("ROI mean:",ROI.mean(),"min:",ROI.min(),"max:",ROI.max(),"shape:",ROI.shape) if len(ROI) is not len(data): print("skipping this analysis len(data)",len(data),"len(ROI)",len(ROI)) continue patientsuffix = patID + infos["time"] his, allhistos, histogiafatti,histogclm = make_histo(data,ROI,patientsuffix, args.verbose,roinorm,args.norm,args.icut,args.filter) entropy_his, allentropy_his = make_histo_entropy(data,ROI,patientsuffix, args.verbose) nVoxel[0] = int(his.GetEntries()) mean[0] = his.GetMean() stdDev[0] = his.GetStdDev() skewness[0] = his.GetSkewness() kurtosis[0] = his.GetKurtosis() entropy_mean[0] = entropy_his.GetMean() entropy_var[0] = entropy_his.GetStdDev() if args.verbose: print(patientID, timeflag[0], nVoxel[0], ypT[0], mean[0], stdDev[0], skewness[0], kurtosis[0]) his.Write() entropy_his.Write()
if args.norm: myroifilename = lines[5] roireader = roiFileHandler(args.verbose) myroisnorm, roisnormSetted = roireader.read(myroifilename) roinorm = myroi2roi(myroisnorm, data.shape, args.verbose) if args.verbose: print("norm file read") patientsuffix=lines[0]+str(timeflag[0]) if timeflag[0] != 0 and timeflag[0] != 1 and timeflag[0] != 2: print("ERROR: timeflag (0 for pre, 1 for int and 2 for post) of patient "+lines[0]+ "is: "+timeflag[0]) raise NameError('OutOfRange') his, allhistos, histogiafatti = make_histo(data,ROI,patientsuffix,args.verbose,roinorm,args.norm) nVoxel[0] = int(his.GetEntries()) mean[0] = his.GetMean() stdDev[0] = his.GetStdDev() skewness[0] = his.GetSkewness() kurtosis[0] = his.GetKurtosis() if args.verbose: print(patientID, timeflag[0], nVoxel[0], ypT[0], mean[0], stdDev[0], skewness[0], kurtosis[0]) his.Write() for thishisto in allhistos: if thishisto.GetEntries() >0: nVoxelPF[nFette[0]] = int(thishisto.GetEntries()) meanPF[nFette[0]] = thishisto.GetMean() stdDevPF[nFette[0]] = thishisto.GetStdDev() skewnessPF[nFette[0]] = thishisto.GetSkewness()
roireader = roiFileHandler(args.verbose) myroisnorm, roisnormSetted = roireader.read(myroifilename) roinorm = myroi2roi(myroisnorm, data.shape, args.verbose) if args.verbose: print("norm file read") if args.verbose: print("data mean:",data.mean(),"min:",data.min(),"max:",data.max(),"shape:",data.shape) print("ROI mean:",ROI.mean(),"min:",ROI.min(),"max:",ROI.max(),"shape:",ROI.shape) patientsuffix=lines[0]+str(timeflag[0]) if timeflag[0] != 0 and timeflag[0] != 1 and timeflag[0] != 2: print("ERROR: timeflag (0 for pre, 1 for int and 2 for post) of patient "+lines[0]+ "is: "+timeflag[0]) raise NameError('OutOfRange') his, allhistos, histogiafatti,histogclm = make_histo(data,ROI,patientsuffix,args.verbose,roinorm,args.norm,args.icut,args.filter) nVoxel[0] = int(his.GetEntries()) mean[0] = his.GetMean() stdDev[0] = his.GetStdDev() skewness[0] = his.GetSkewness() kurtosis[0] = his.GetKurtosis() if args.verbose: print(patientID, timeflag[0], nVoxel[0], ypT[0], mean[0], stdDev[0], skewness[0], kurtosis[0]) his.Write() for thishisto in allhistos: if thishisto.GetEntries() >0: nVoxelPF[nFette[0]] = int(thishisto.GetEntries()) meanPF[nFette[0]] = thishisto.GetMean() stdDevPF[nFette[0]] = thishisto.GetStdDev() skewnessPF[nFette[0]] = thishisto.GetSkewness()
# for infileROI in infilesROI: # dicomsROI.append(dicom.read_file(infileROI)) # for i, thisROI in enumerate(dicomsROI): # pix_arr = thisROI.pixel_array # ROI[i] = pix_arr.T # for i, thisdicom in enumerate(dicoms): # pix_arr = thisdicom.pixel_array # data[i] = pix_arr.T data, ROI = read_files(inpath,args.filterROI, args.verbose, True) outfile= ROOT.TFile(outfname,"RECREATE") his, allhistos = make_histo(data,ROI) his.Write() for thishisto in allhistos: thishisto.Write() # histograms = [] # for i, fetta, fettaROI in enumerate(zip(data,ROI)): # if fettaROI.max() > 0 : # histogram = make_histo(fetta, fettaROI) # histogram.SetName("h"+str(i)) # histogram.SetTitle("h"+str(i)) # histogram.Write() outfile.Write()
# dicomsROI.append(dicom.read_file(infileROI)) # for i, thisROI in enumerate(dicomsROI): # pix_arr = thisROI.pixel_array # ROI[i] = pix_arr.T # for i, thisdicom in enumerate(dicoms): # pix_arr = thisdicom.pixel_array # data[i] = pix_arr.T data, ROI = read_files(inpath, args.filterROI, args.verbose, True) outfile = ROOT.TFile(outfname, "RECREATE") if args.filterROI: his, allhistos = make_histo(data, ROI) his.Write() else: allhistos = make_histo_ofallpixels(data, "", args.verbose, args.normalize) for thishisto in allhistos: thishisto.Write() # histograms = [] # for i, fetta, fettaROI in enumerate(zip(data,ROI)): # if fettaROI.max() > 0 : # histogram = make_histo(fetta, fettaROI) # histogram.SetName("h"+str(i)) # histogram.SetTitle("h"+str(i)) # histogram.Write()