Skip to content

Commit

Permalink
Merge branch 'jamieboss:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wcray authored Feb 28, 2022
2 parents 7486ae9 + b44a61e commit 579d894
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
Binary file modified .DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# R21-doppler
## Running the program
Open and run the file 'cbfFull.py'.

Follow the prompts to:
- Select the folderpath containing the videos to be analyzed.
- Input a name for the excel file to be generated by the program.
- Select the method of analysis (Doppler will analyzed only videos for blood flow velocity, Colormode will additionally analyze videos for vessel diameters).
- Select the files to be analyzed. Multiple baseline or hyperemic Doppler videos should be selected all at once. For Colormode analysis, only one baseline and hyperemic colormode file each should be selected.
- If Colormode analysis was selected, input the probe angle and maximum/minimum penetration depth (indicated below).

![colormodeInput](https://user-images.githubusercontent.com/57882373/155819942-1d9129f0-d193-47d9-a8d1-dffbfb441b31.png)

The program will automatically parse each video file into a single image and attempt to binarize the image in order to capture the Doppler envelope and remove. The user can verify or adjust this threshold value in the 'Scroll Test' window that appears (shown below).

<img width="1294" alt="Screen Shot 2022-02-25 at 7 11 06 PM" src="https://user-images.githubusercontent.com/57882373/155819957-1ebce476-8267-4cd3-8fe0-07033c30fc15.png">

The program will complete its analysis and output the following files:
- An excel file with the input name containing all calculated data points. This will be in the same directory as the analyzed video files.
- Images named using the input file name + "_#", labeled in the order that video files were analyzed. These images label the following data points for each cardiac cycle: beginning of cycle (green), peak velocity (yellow), decay velocity (pink), peak diastolic deceleration (red), and end of cycle (blue).
- For colormode analysis, images named "baseline_###" and "hyperemic_###", with numbers corresponding to that image's identified vessel diameter.
Binary file modified __pycache__/vevoAVIparser.cpython-37.pyc
Binary file not shown.
14 changes: 6 additions & 8 deletions cbfFull.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
#Select folder containing video files to be analyzed
root = tkinter.Tk()
root.withdraw()
#folderpath = filedialog.askdirectory(parent = root, initialdir = "/", title = "Select Folder Path")
folderpath = '/Users/jamieb/Documents/videos'
folderpath = filedialog.askdirectory(parent = root, initialdir = "/", title = "Select Folder Path")

#Input filename where doppler analysis results will be stored
savefile = filedialog.asksaveasfilename(parent = root, initialdir = folderpath, title = "Save Results As:")
Expand Down Expand Up @@ -72,7 +71,6 @@
pics.append(pictureBL)
TP.append(timeperpixelBL)
velocityMax.append(maxVel) #Store maximum velocity
print('MaxVel: ' + str(maxVel))



Expand Down Expand Up @@ -261,10 +259,10 @@
count+=1

#View ecg peaks
peakImg = ecgRegionBinary
peakImg.T[locs] = 255
filenamepeak = 'peaks' + str(countALL) + '.png'
cv2.imwrite(filenamepeak, peakImg)
#peakImg = ecgRegionBinary
#peakImg.T[locs] = 255
#filenamepeak = 'peaks' + str(countALL) + '.png'
#cv2.imwrite(filenamepeak, peakImg)

#Calculate beats-per-minute
bpm = []
Expand Down Expand Up @@ -332,7 +330,7 @@
#Diastolic velocity or beginning of diastolic phase (BD)
fifteenCycle = (timeCycle[-1]-timeCycle[0]) * .075 #7.5% of total beat duration
fifteenWinStart = timeCycle[PDAloc] - fifteenCycle #Time 7.5% prior to peak
k

index15 = np.argmin([abs(x - fifteenWinStart) for x in timeCycle]) #Find index of time closest to %7.5
DV1vel = min(filtEnvelope[index15:PDAloc+1]) #Decay velocity
DV1time = timeCycle[[i for i, x in enumerate(filtEnvelope) if x == DV1vel][0]] #Decay velocity time
Expand Down
7 changes: 3 additions & 4 deletions vevoAVIparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def parse(videoFile):

#Values depending on video size
##Note: [slider bar row, slider bar column, temperature black-out, Vevo logo black-out, slide bar minimum]
print('height: ' + str(height) + ' width: ' + str(width))
#print('height: ' + str(height) + ' width: ' + str(width))
if width == 880 and height == 666:
values = [378, 772, 830, 34, 500]
elif width == 1168 and height == 864:
Expand All @@ -89,7 +89,7 @@ def parse(videoFile):
else:
#Default values
values = [round(0.567 * height), round(0.875 * width), round(0.895 * width), round(0.125*height)-67, 1000]
print('Using values: ' + str(values))
#print('Using values: ' + str(values))



Expand Down Expand Up @@ -221,7 +221,6 @@ def parse(videoFile):
newsplitscroll.append(index + c)

newsplitscroll = list(dict.fromkeys(newsplitscroll))
print(newsplitscroll)

###Merge images around slider bar reset
newFirst = []
Expand Down Expand Up @@ -273,6 +272,6 @@ def parse(videoFile):
wholeSequence = wholeSequence[values[3]-1:, :] #Remove Vevo logo
(c, length) = wholeSequence.shape #Find pixel length of image
timeperpixel = length / duration / 10 #Calculate time-per-pixel
cv2.imwrite('test.png', wholeSequence) #View parsed image
#cv2.imwrite('test.png', wholeSequence) #View parsed image

return wholeSequence, timeperpixel, maxVel

0 comments on commit 579d894

Please sign in to comment.