TITLE: Protocol for the preparation of Wings and Wing Interference Pattern Imaging from ethanol preserved specimens
AUTHORS: Saskia B. Bartsch, Jonathan Vogel, Anne Ankermann, Christoph Mayer, Ralph S. Peters

[DESCRIPTION]
This protocol aims to provide standardisation for the necessary steps, specifically to a) produce standardised, artifact-free and high-quality WIP images, b) secure long-term-storage of the specimens, c) make the prepared wings re-traceable to the specimens they have been taken from d) secure reproducibility of the imaging even decades after preparation (i.e., easy cleaning of the wing specimens prior to imaging), and to e) allow reproduction of the protocol with minimal financial resources. In all these aspects, there is undeniably room for improvement.

[BEFORE_START]
The protocol is tested for both DNA-lysed and unlysed samples in high-% EtOH. While both scenarios worked, we found it a little easier to detach the wings (step 1) from the lysed samples.

[STEPS]
SECTION: Slide preparation
1. Using the microscope, transfer the ethanol-preserved specimen into a small petri dish or staining block filled with ethanol. 
Dissect the right fore- and hindwings of the specimen by grabbing the base of the forewing with the fine forceps and spinning the wing while pushing the specimen into the opposite direction until the wing detaches. 
Repeat with the hindwing.
SECTION: Slide preparation
2. Transfer the remaining specimen back into its labelled tube or proceed with mounting the specimen.
Clean a microscopic slide with ethanol and a microfiber cloth. 
Position the printed alignment sheet ( ) underneath the slide.
SECTION: Slide preparation
3. Place a small drop of ethanol in the centre of the slide.
Under the microscope, using forceps, transfer the fore- and hindwings into the ethanol drop.
SECTION: Slide preparation
4. Align the fore- and hindwings according to the alignment sheet (see step 5) for standardised positioning and easier comparison. Make sure the fore- and hindwings do not overlap and are stretched out as good as possible. If too little ethanol is used on the slide, the wings are prone to rip apart when moved.
SECTION: Slide preparation
5. Gently place the coverslip on top to protect the wings from dust and damage for long-time storage.
Add an additional drop of ethanol on the coverslip's edge and gently push the slip down with the forceps right above the wings to push potential air bubbles to the side. Avoid pushing too hard to not break the coverslip and not adhese the glasses. The latter is important as the WIPs will not show otherwise.
Allow the ethanol to evaporate. 
SECTION: Slide preparation
6. Gently apply a small amount of clear nail polish (enough to stabilize the slip but without it reaching the wings) to the coverslip edges using a small 00- or 000-type brush and let the nail polish harden.
SECTION: Slide preparation
7. Label the slide to link the wings to the corresponding specimen.
SECTION: Imaging
8. See Materials for hard- and software used and prepare accordingly.
Configure the camera settings:
Exposure time: 100ms
Saturation: 20 (maximum)
Contrast: Maximum
Magnification: 34.5X
Colour mode: RGB
Histogram: Best fit
SECTION: Imaging
9. Put the slide with the wings on the ring light, the black painted cardboard behind it and the dome on top
SECTION: Imaging
10. Bring the wing in focus, adjust white balance (Auto) and snapshot the image
SECTION: Imaging
11. Apply a scalebar to the image and export the image in a file format of choice
SECTION: Image Processing
12. In GIMP, adjust luminance values by navigating to Colours/Levels. A window will pop up. Drag the min input level slider (black triangle) to the lowest visible margin of the input level curve and drag the max input level slider (white triangle) to the highest visible margin of the input level curve (see image). The visibility of the curve can be improved by dragging the window to full screen.
 

SECTION: Image Processing
13. The python scripts of the following steps can be accessed via https://github.com/aankm/WIP_auto-img. 
Isolate the wings: In order to remove extraneous signal from the images, isolate the wings from the
background. As is, the script will save the forewing and hindwing for each individual in separate files. The two wings are processed separately and recombined to a final image in a standardised way after the following sub-steps. 
Note: To maintain the wings’ orientation to each other, combine both contours.
-> 01-extract_foreground.py
SECTION: Image Processing
14. If magnification and resolution differ within the series of images: Re-size images to put them to scale.
SECTION: Image Processing
15. Standardize orientation: Rotate the images so that the back margin of the forewing and the front margin of the hindwing were horizontal. The rotation function was customised from an OpenCV interactive grabcut algorithm available at https://github.com/opencv/opencv/blob/master/samples/python/grabcut.py The program opens a new window and prompts the user to draw a line in the image indicating the edge that should be horizontally aligned. The difference between the angle of this line and the 0° horizontal is calculated and the image rotated accordingly. Note that it is important to keep the direction (start and end points) of the guiding line consistent. Use any two consistent landmarks across the dataset. 
-> 02-interactive_rotation.py
SECTION: Image Processing
13.1. Create a mask from the contours detected in the image with the edge detection function cv2.Canny() by overlaying the edges with small circles of the same solid colour (grey). The size of the circles should be selected so that all edges within the desired foreground area connect into one shape. Fill all areas outside this shape with a solid colour. If the background is too noisy, this step may not work as desired.
SECTION: Image Processing
13.2. Find all contours (read: continuous objects) within the mask using cv2.findContours(), and sort them by area size in decreasing order.
SECTION: Image Processing
13.3. Fill the largest contour of the mask (the forewing) in a different solid colour (white). Use this mask to black out all areas of a copy of the original image that are not part of the foreground object.
SECTION: Image Processing
13.4. Repeat the preceding step for the second largest contour (the hindwing). 
Note: If the forewing and hindwing areas intersect, or one part is missing (due to lost or generally missing wing as in, for example, Diptera), make these steps conditional on the size of the contours.
SECTION: Image Processing
16. Crop isolated and rotated images to their minimum possible size and combine the fore- and hindwings into one image. 
-> 03-crop_combine.py
SECTION: Image Processing
16.1. Create a mask from the contours detected in the image with the edge detection function cv2.Canny() by overlaying the edges with small circles of the same solid colour (grey). The size of the circles should be selected so that all edges within the desired foreground area connect into one shape. Fill all areas outside this shape with a solid colour.
SECTION: Image Processing
16.2. Find all contours (read: continuous objects) within the mask using cv2.findContours(). There should be one contour in each image, since the wings were already isolated.
SECTION: Image Processing
16.3. Find the minimum dimensions of the wing contours (cv2.boundingRect()), and crop the image to the corresponding coordinates.
SECTION: Image Processing
16.4. Using the bounding rectangle dimensions, place the wings into a blank background with specified distance from the edges and each other. A standardised scale can be placed into the images.
SECTION: Image Processing
17. If necessary, adjust the brightness of the images to the same level. Do this after removing the background and exclude black pixels from the calculation. 
-> 04-adjust_brightness.py