|
1 |
| -# ocelot23algo Algorithm |
| 1 | +# OCELOT23: The algorithm |
| 2 | + |
| 3 | +In this repository you will find the source code for the Grand Challenge OCELOT23 algorithm container. Ocelot is both a MICCAI challenge and an accepeted paper at CVPR 23. |
| 4 | + |
| 5 | +# Input and output |
| 6 | + |
| 7 | +* The input: the container searches loads and iterates over the validation images, test images and metadata from the already uploaded data in Grand Challenge. The implemented loader `DataLoader` at `util.gcio.py` will iterate over the samples for you!. |
2 | 8 |
|
3 |
| -The source code for the algorithm container for |
4 |
| -ocelot23algo, generated with |
5 |
| -evalutils version 0.4.0 |
6 |
| -using Python 3.9. |
| 9 | +* The output: your algorithm needs to predict cells with the Multiple Points format. To make things easier like with the data loader, we implemented a simple writer class `DetectionWriter` to output the corresponding output file `cell_predictions.json`. An example of the output can be found in `test/output/example_output.json`. |
| 10 | + |
| 11 | +```json |
| 12 | +{ |
| 13 | + "type": "Multiple points", |
| 14 | + "points": [ |
| 15 | + { |
| 16 | + "name": "0", |
| 17 | + "point": [ |
| 18 | + 128.0, |
| 19 | + 620.0, |
| 20 | + 1.0 |
| 21 | + ], |
| 22 | + "probability": 1.0 |
| 23 | + }, |
| 24 | + { |
| 25 | + "name": "0", |
| 26 | + "point": [ |
| 27 | + 128.0, |
| 28 | + 621.0, |
| 29 | + 1.0 |
| 30 | + ], |
| 31 | + "probability": 1.0 |
| 32 | + }, |
| 33 | +``` |
| 34 | + |
| 35 | +# Develop you algorithm |
| 36 | + |
| 37 | +At `user/inference.py` you will find a dummy cell detection algorithm. Your task is to modify the function `process_patch_pair` trying to keep the format used below. Feel free to install any framework, such as PyTorch or Tensorflow to run your code. In addition, do not forget to add your dependencies in `requirement.txt` so that your container can be build correctly. |
| 38 | + |
| 39 | +```python |
| 40 | +def process_patch_pair(cell_patch, tissue_patch, pair_id, meta_dataset): |
| 41 | + """This function detects the cells in the cell patch, while additionally |
| 42 | + providing the broader tissue context |
| 43 | + |
| 44 | + NOTE: this function offers a dummy example inference code. This must be |
| 45 | + updated by the participant. |
| 46 | + |
| 47 | + Parameters |
| 48 | + ---------- |
| 49 | + cell_patch: np.ndarray |
| 50 | + Cell patch with shape [3, 1024, 1024] |
| 51 | + tissue_patch: np.ndarray |
| 52 | + Tissue patch with shape [3, 1024, 1024] |
| 53 | + pair_id: str |
| 54 | + identification number of the patch pair |
| 55 | + meta_dataset: Dict |
| 56 | + Dataset metadata in case you wish to compute statistics |
| 57 | + |
| 58 | + Returns |
| 59 | + ------- |
| 60 | + List[tuple]: list of tuples (x,y) coordinates of detections |
| 61 | + """ |
| 62 | + # Getting the metadata corresponding to the patch pair ID |
| 63 | + meta_pair = meta_dataset[pair_id] |
| 64 | + |
| 65 | + ############################################# |
| 66 | + #### YOUR INFERENCE ALGORITHM GOES HERE ##### |
| 67 | + ############################################# |
| 68 | + |
| 69 | + # The following is a dummy cell detection algoritm |
| 70 | + prediction = np.copy(cell_patch[2, :, :]) |
| 71 | + prediction[(cell_patch[2, :, :] <= 40)] = 1 |
| 72 | + xs, ys = np.where(prediction.transpose() == 1) |
| 73 | + probs = [1.0] * len(xs) # Confidence score |
| 74 | + class_id = [1] * len(xs) # Type of cell |
| 75 | + |
| 76 | + ############################################# |
| 77 | + ####### RETURN RESULS PER SAMPLE ############ |
| 78 | + ############################################# |
| 79 | + |
| 80 | + # We need to return a list of tuples with 4 elements, i.e.: |
| 81 | + # - cell's x-coordinate in the cell patch |
| 82 | + # - cell's y-coordinate in the cell patch |
| 83 | + # - class id of the cell, either 1 (BC) or 2 (TC) |
| 84 | + # - confidence score of the predicted cell |
| 85 | + return list(zip(xs, ys, class_id, probs)) |
| 86 | +``` |
| 87 | + |
| 88 | +# Submitting to GC |
| 89 | + |
| 90 | +To submit your algorithm to the GC platform, you'll need to export the docker container wrapping your code. |
| 91 | + |
| 92 | +### Build your docker image |
| 93 | + |
| 94 | +```bash |
| 95 | +bash build.sh |
| 96 | +``` |
| 97 | + |
| 98 | +### Testing before submitting to GC |
| 99 | + |
| 100 | +Before submitting your containers to GC, make sure this simple test works in your local machine. This script will create the image, run the container and verify that the output `cell_predictions.json` at the output directory. To do so, run the following command: |
| 101 | + |
| 102 | +```bash |
| 103 | +bash test.sh |
| 104 | +``` |
| 105 | +### Export algorithm docker image |
| 106 | + |
| 107 | +Generate the `tar` file to be uploaded to GC by running the following command: |
| 108 | + |
| 109 | +```bash |
| 110 | +bash export.sh |
| 111 | +``` |
| 112 | + |
| 113 | +# Cite |
0 commit comments