From c61dd34d8321f8f0e1ad0802fdd10415b622d352 Mon Sep 17 00:00:00 2001 From: roll Date: Tue, 29 Aug 2017 11:06:26 +0300 Subject: [PATCH 01/22] Ensure datapackage<1.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7ff21c9..039ee49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -datapackage +datapackage<1.0 jsontableschema jsontableschema-pandas From 8d2f46237269111fb243fda8993f809872128272 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Mon, 23 Oct 2017 16:12:14 +0200 Subject: [PATCH 02/22] readme for mosaic example --- examples/Mosaic/readme.md | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/Mosaic/readme.md diff --git a/examples/Mosaic/readme.md b/examples/Mosaic/readme.md new file mode 100644 index 0000000..19169b9 --- /dev/null +++ b/examples/Mosaic/readme.md @@ -0,0 +1,41 @@ +## Mosaic example + +The example in the *Mosaic* directory was generated using the [MosaicSuite plugin](http://mosaic.mpi-cbg.de/?q=downloads/imageJ) for ImageJ/Fiji. + +Version used: `MosaicSuite-1.0.8`. + +### Example 1 +The dataset used in this example is the same used in the [TrackMate](../TrackMate) and other examples. The images were both detected and tracked using the Mosaic Particle Tracker tool. + +#### The test dataset +The test dataset used can be uploaded in ImageJ: + +`File ▶ Open Samples ▶ Tracks for TrackMate (807K)` + +You can then open and run the Mosaic plugin selecting: + +`Plugins ▶ Mosaic ▶ Particle Tracker 2D/3D ` + +Alternatively, you can download the data from this [link](http://fiji.sc/samples/FakeTracks.tif). + +#### Settings to reproduce the two examples +To reproduce the example in this directory, you need to choose the following settings + +- Detection settings: + - Kernel radius: 5 + - Cutoff radius: 0.01 + - Percentile: 0.4 +- Tracking settings: + - Displacement: 10.0 + - Linkrange: 3 + +Once you run the tracking, you can select **All Trajectories to Table**, which opens an ImageJ table that you can save to disk. + + +#### Running the data_package library +Move to the example directory and run the data package creation script: + +``` +cd examples/Mosaic/example_1 +python ../../../scripts/create_dpkg.py mosaic_tracks.csv +``` \ No newline at end of file From 768e6a7fe662de9c78f376f36e26c63126c52426 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Mon, 23 Oct 2017 16:12:55 +0200 Subject: [PATCH 03/22] add tracking data --- examples/Mosaic/example_1/mosaic_tracks.csv | 182 ++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 examples/Mosaic/example_1/mosaic_tracks.csv diff --git a/examples/Mosaic/example_1/mosaic_tracks.csv b/examples/Mosaic/example_1/mosaic_tracks.csv new file mode 100644 index 0000000..18fbef4 --- /dev/null +++ b/examples/Mosaic/example_1/mosaic_tracks.csv @@ -0,0 +1,182 @@ +Trajectory Frame x y z m0 m1 m2 m3 m4 NPscore +1 0 64.504 4.413 0 11.746 1.663 3.4 7.696 18.783 0.333 +1 1 64.638 6.528 0 10.934 1.639 3.302 7.369 17.752 0.333 +1 2 64.522 10.52 0 10.444 1.63 3.273 7.276 17.459 0.333 +1 3 64.093 13.027 0 14.807 1.767 3.837 9.277 24.26 0.333 +1 4 62.885 16.847 0 14.428 1.806 3.989 9.8 26.008 0.333 +1 5 60.031 19.994 0 14.954 1.779 3.909 9.612 25.697 0.333 +1 6 60.142 20.007 0 14.659 1.778 3.886 9.454 24.873 0.333 +1 7 58.069 22.073 0 14.164 1.771 3.856 9.344 24.496 0.333 +1 8 58.025 22.998 0 15.31 1.787 3.923 9.584 25.308 0.333 +1 9 62.032 25.995 0 13.826 1.783 3.931 9.693 25.956 0.25 +1 10 63.027 30.027 0 13.886 1.786 3.929 9.645 25.676 0.25 +1 11 63.09 34.013 0 15.525 1.804 4.006 9.928 26.677 0.252 +1 12 63.042 37.092 0 14.123 1.768 3.858 9.407 24.926 0.25 +1 13 63.104 39.053 0 15.205 1.782 3.898 9.484 24.961 0.25 +1 14 63.046 41.173 0 15.616 1.783 3.904 9.527 25.178 0.25 +1 15 64.536 46.881 0 19.476 1.831 4.094 10.165 27.23 0.25 +1 16 64.06 52.089 0 15.24 1.778 3.877 9.397 24.616 0.201 +1 17 64.162 55.992 0 16.172 1.763 3.831 9.31 24.603 0.261 +1 18 62.088 57.962 0 15.439 1.808 4.005 9.872 26.321 0.25 +1 19 59.918 62.929 0 13.484 1.755 3.791 9.124 23.779 0.2 +1 20 59.911 68.057 0 15.189 1.793 3.987 9.973 27.272 0.2 +1 21 60.124 72.931 0 15.765 1.796 3.94 9.596 25.215 0.26 +1 22 59.878 77.098 0 15.291 1.774 3.865 9.365 24.54 0.25 +1 23 60.003 79 0 16.177 1.843 4.188 10.659 29.508 0.2 +1 24 59.966 80.077 0 14.801 1.76 3.817 9.24 24.261 0.2 +1 25 60.044 80.008 0 15.731 1.785 3.934 9.7 26.008 0.2 +1 26 54.081 83.065 0 16.769 2.329 7.058 24.859 96.608 0.2 +1 27 52.02 87.071 0 14.658 1.774 3.875 9.439 24.905 0.25 +1 28 52.13 91.958 0 15.864 1.796 3.952 9.668 25.552 0.25 +1 29 51.835 93.64 0 12.296 1.689 3.507 8.09 20.171 0.25 +1 30 52.025 98.191 0 14.826 1.775 3.87 9.39 24.657 0.333 +1 31 51.997 98.962 0 15.765 1.781 3.91 9.584 25.492 0.333 +1 32 51.978 101.036 0 14.238 1.789 3.938 9.667 25.701 0.333 +1 33 52.07 102.979 0 15.758 1.822 4.099 10.326 28.288 0.333 +1 34 52.179 104.012 0 14.222 1.772 3.884 9.567 25.771 0.333 +1 35 52.124 105.012 0 14.447 1.778 3.883 9.441 24.826 0.333 +1 36 52.031 108.026 0 14.669 1.781 3.904 9.547 25.306 0.333 +1 37 52.014 108.958 0 15.217 1.783 3.925 9.679 25.993 0.333 +1 38 52.051 112.025 0 14.828 1.779 3.881 9.418 24.7 0.333 +1 39 52.012 115.05 0 15.767 1.81 4.033 10.045 27.166 0.25 +1 40 51.953 117.928 0 14.331 1.791 3.947 9.708 25.886 0.25 +1 41 51.995 121.095 0 15.511 1.785 3.919 9.583 25.368 0.25 +2 0 105.091 112.859 0 5.759 1.661 3.437 7.973 20.17 0.333 +2 1 104.902 113.101 0 4.679 1.684 3.566 8.552 22.634 0.333 +2 2 104.985 113.009 0 4.019 1.617 3.275 7.434 18.393 0.333 +2 3 104.991 112.987 0 5.414 1.701 3.611 8.607 22.379 0.333 +2 4 104.838 112.924 0 5.338 1.735 3.747 9.089 24.063 0.333 +2 5 105.097 112.92 0 6.31 1.712 3.641 8.698 22.722 0.333 +2 6 105.198 113.472 0 5.633 1.658 3.394 7.736 19.111 0.333 +2 7 105.035 112.879 0 4.369 1.705 3.687 9.16 25.545 0.333 +2 8 105.204 112.769 0 4.913 1.615 3.255 7.381 18.436 0.333 +2 9 105.087 113.139 0 4.673 1.631 3.286 7.352 17.792 0.25 +2 10 104.727 113.275 0 4.662 1.722 3.707 9.027 24.215 0.25 +2 11 105.006 112.807 0 5.694 1.747 3.808 9.355 25.194 0.25 +2 12 105.134 112.944 0 6.2 1.719 3.694 8.969 23.945 0.25 +2 13 104.836 113.288 0 5.49 1.642 3.337 7.552 18.54 0.25 +2 14 105.03 113.473 0 4.485 1.624 3.309 7.595 19.149 0.25 +2 15 105.204 112.854 0 5.812 1.61 3.212 7.136 17.195 0.25 +2 16 104.902 113.298 0 5.152 1.73 3.744 9.145 24.512 0.2 +2 19 104.886 112.839 0 5.784 1.688 3.539 8.311 21.272 0.2 +2 20 105.004 112.954 0 4.511 1.655 3.422 7.929 20.024 0.2 +2 21 105.025 112.897 0 5.183 1.588 3.144 6.953 16.742 0.2 +2 23 104.758 112.898 0 5.173 1.664 3.444 7.972 20.097 0.2 +2 24 105.027 113.059 0 5.097 1.739 3.774 9.21 24.545 0.2 +2 25 105.187 113.018 0 6.126 1.707 3.62 8.608 22.311 0.2 +2 26 105.357 112.944 0 5.616 1.72 3.66 8.695 22.407 0.2 +2 27 104.561 112.979 0 4.366 1.622 3.363 8.065 22.04 0.25 +2 28 105.197 113.117 0 4.6 1.657 3.412 7.847 19.606 0.25 +2 29 105.029 113.083 0 4.711 1.743 3.777 9.18 24.305 0.25 +2 30 104.838 112.817 0 4.842 1.6 3.155 6.895 16.286 0.333 +2 31 105.05 113.176 0 5.324 1.694 3.574 8.44 21.684 0.333 +2 32 104.918 113.093 0 4.81 1.612 3.247 7.333 18.08 0.333 +2 33 105.089 112.742 0 4.521 1.713 3.631 8.597 22.129 0.333 +2 34 104.723 112.971 0 4.695 1.686 3.548 8.414 21.904 0.333 +2 35 104.905 112.872 0 4.42 1.656 3.473 8.37 22.835 0.333 +2 36 105.023 113.192 0 4.967 1.707 3.648 8.765 22.987 0.333 +2 37 104.959 113.119 0 5.148 1.717 3.673 8.84 23.297 0.333 +2 38 105.169 112.888 0 4.49 1.644 3.365 7.734 19.455 0.333 +2 39 105.056 113.299 0 4.135 1.657 3.417 7.869 19.695 0.25 +2 40 104.798 113.054 0 4.794 1.59 3.138 6.902 16.495 0.25 +2 41 105.016 112.754 0 4.249 1.708 3.644 8.755 23.029 0.25 +2 42 104.795 113.034 0 3.894 1.775 4.058 10.793 32.394 0.333 +2 43 105.12 113.347 0 5.461 1.619 3.237 7.184 17.232 0.333 +2 44 105.18 112.897 0 5.148 1.655 3.412 7.874 19.816 0.143 +2 45 104.951 113.099 0 5.031 1.623 3.28 7.414 18.269 0.333 +2 46 105.031 112.728 0 5.191 1.696 3.573 8.419 21.602 0.333 +2 47 104.938 112.765 0 5.787 1.67 3.462 7.999 20.036 0.333 +2 48 104.595 112.726 0 4.821 1.728 3.714 8.993 23.931 0.333 +2 49 104.632 113.1 0 4.731 1.832 4.336 11.977 37.385 0.333 +3 0 116.776 116.691 0 12.079 2.353 6.845 22.421 79.66 0.333 +3 1 116.72 116.655 0 12.515 2.24 6.203 19.353 65.651 0.333 +3 2 116.835 116.512 0 12.604 2.3 6.526 20.844 72.268 0.333 +3 3 116.85 116.482 0 12.305 2.236 6.199 19.431 66.41 0.333 +3 4 116.889 116.397 0 11.648 2.256 6.275 19.64 66.749 0.333 +3 5 116.737 116.591 0 12.504 2.373 6.983 23.145 83.203 0.333 +3 6 116.788 116.491 0 12.299 2.247 6.245 19.579 66.812 0.333 +3 7 116.867 116.533 0 12.44 2.341 6.762 21.976 77.414 0.333 +3 8 116.894 116.454 0 12.402 2.256 6.274 19.664 67.078 0.333 +3 9 116.813 116.513 0 12.509 2.392 7.083 23.635 85.53 0.25 +3 10 116.679 116.345 0 12.003 2.24 6.204 19.375 65.844 0.25 +3 11 116.751 116.352 0 11.923 2.266 6.39 20.414 71.164 0.25 +3 12 116.834 116.458 0 12.756 2.336 6.749 21.982 77.736 0.25 +3 13 116.92 116.941 0 12.654 2.347 6.836 22.542 81.062 0.25 +3 14 116.844 116.561 0 12.538 2.349 6.822 22.303 79.08 0.25 +3 15 116.826 116.564 0 12.644 2.308 6.586 21.216 74.372 0.25 +3 16 116.932 116.506 0 12.051 2.317 6.651 21.516 75.568 0.2 +3 17 116.861 116.575 0 12.96 2.324 6.674 21.618 76.174 0.25 +3 18 116.726 116.443 0 12.215 2.342 6.792 22.212 78.867 0.25 +3 19 116.735 116.437 0 12.18 2.247 6.255 19.687 67.576 0.2 +3 20 116.821 116.398 0 11.784 2.293 6.532 21.012 73.487 0.2 +3 21 116.862 116.522 0 12.715 2.348 6.815 22.291 79.162 0.2 +3 22 116.791 116.559 0 12.175 2.29 6.493 20.759 72.117 0.25 +3 23 116.736 116.459 0 12.427 2.318 6.643 21.468 75.425 0.2 +3 24 116.78 116.329 0 11.653 2.269 6.399 20.413 70.941 0.2 +3 25 116.786 116.602 0 12.541 2.279 6.365 19.926 67.506 0.2 +3 26 116.8 116.554 0 11.956 2.296 6.524 20.893 72.696 0.2 +3 27 116.895 116.693 0 12.876 2.324 6.669 21.529 75.369 0.25 +3 28 116.768 116.587 0 12.622 2.262 6.318 19.914 68.347 0.25 +3 29 116.822 116.452 0 12.242 2.308 6.639 21.609 76.607 0.25 +3 30 116.815 116.432 0 11.85 2.329 6.686 21.577 75.453 0.333 +3 31 116.883 116.45 0 12.223 2.246 6.224 19.406 65.708 0.333 +3 32 116.871 116.413 0 12.314 2.369 6.957 23.046 82.888 0.333 +3 33 116.74 116.997 0 12.98 2.353 6.911 23 83.404 0.333 +3 34 116.78 116.497 0 12.444 2.274 6.383 20.18 69.322 0.333 +3 35 116.74 116.556 0 12.344 2.322 6.647 21.392 74.639 0.333 +3 36 116.808 116.604 0 12.779 2.426 7.25 24.333 88.364 0.333 +3 37 116.67 115.45 0 9.859 1.915 4.57 12.351 36.611 0.333 +3 38 116.698 116.491 0 11.934 2.298 6.522 20.815 72.056 0.333 +3 39 116.75 116.446 0 12.13 2.276 6.423 20.48 71.1 0.25 +3 40 116.814 116.483 0 12.939 2.329 6.731 21.955 77.842 0.25 +3 41 116.73 116.509 0 12.313 2.303 6.578 21.248 74.745 0.25 +3 42 116.805 116.626 0 12.819 2.328 6.705 21.783 76.897 0.333 +3 43 116.869 116.48 0 12.845 2.316 6.641 21.493 75.646 0.333 +3 44 116.847 116.473 0 12.554 2.309 6.588 21.177 73.904 0.143 +3 45 116.78 116.43 0 12.376 2.336 6.762 22.081 78.321 0.333 +3 46 116.906 116.662 0 12.937 2.374 6.953 22.888 81.626 0.333 +3 47 116.806 116.615 0 12.909 2.346 6.782 22.054 77.733 0.333 +3 48 116.707 116.504 0 12.313 2.315 6.625 21.375 74.939 0.333 +3 49 116.754 116.455 0 12.193 2.284 6.437 20.408 70.212 0.333 +4 9 53.017 26.112 0 14.457 1.767 3.848 9.34 24.562 0.25 +4 10 49.925 28.943 0 14.642 1.77 3.846 9.296 24.29 0.25 +4 11 49.071 30.068 0 15.83 1.807 3.997 9.827 26.091 0.252 +4 12 46.095 33.003 0 14.915 1.792 3.962 9.791 26.288 0.25 +4 13 42.907 34.818 0 15.617 1.799 3.968 9.74 25.852 0.25 +4 14 40.079 37.881 0 15.036 1.78 3.883 9.407 24.61 0.25 +4 15 36.984 42.031 0 14.329 1.828 4.152 10.639 29.876 0.25 +4 16 32.891 44.968 0 14.918 1.768 3.83 9.216 23.947 0.204 +4 17 27.984 47.056 0 13.477 1.774 3.883 9.487 25.133 0.25 +4 18 23.98 50.105 0 14.183 1.766 3.836 9.285 24.332 0.25 +4 19 17.911 47.952 0 14.307 1.753 3.775 9.048 23.46 0.2 +4 20 12.916 44.98 0 14.427 1.8 3.991 9.887 26.573 0.2 +4 21 9.961 41.062 0 15.811 1.816 4.089 10.351 28.63 0.26 +4 22 9.949 37.076 0 14.195 1.805 4.024 10.05 27.321 0.25 +4 23 9.934 32.972 0 14.264 1.774 3.879 9.468 25.066 0.268 +4 24 9.965 28.024 0 13.851 1.796 3.973 9.816 26.306 0.2 +4 25 9.95 23.002 0 15.194 1.826 4.115 10.394 28.575 0.202 +4 26 10.166 18.017 0 15.259 1.795 3.957 9.71 25.786 0.2 +4 27 14.033 15.019 0 15.525 1.813 4.071 10.271 28.272 0.25 +4 28 19.181 13.049 0 14.897 1.777 3.905 9.618 25.793 0.25 +4 29 23.125 10.96 0 15.139 1.795 3.974 9.847 26.548 0.25 +5 16 42.106 48.086 0 14.64 1.75 3.757 8.971 23.166 0.203 +5 17 41.977 52.06 0 16.18 1.821 4.079 10.205 27.698 0.261 +5 18 42.021 55.074 0 14.713 1.776 3.891 9.518 25.257 0.25 +5 19 42.169 56.986 0 14.632 1.778 3.903 9.586 25.594 0.2 +5 20 41.966 60.028 0 15.652 1.796 3.966 9.767 26.071 0.2 +5 21 42.004 63.964 0 15.437 1.801 3.995 9.9 26.625 0.201 +5 22 42.109 68.037 0 14.626 1.805 4.001 9.886 26.471 0.25 +5 23 42.015 71.977 0 14.131 1.76 3.817 9.23 24.186 0.268 +5 24 42.066 76.076 0 15.323 1.775 3.873 9.412 24.753 0.2 +5 25 44.932 79.962 0 14.981 1.781 3.9 9.516 25.135 0.202 +5 26 49.915 82.908 0 16.501 2.229 6.528 22.47 86.189 0.2 +6 39 108.864 19.074 0 14.914 1.753 3.772 9.017 23.299 0.25 +6 40 108.886 24.02 0 13.964 1.751 3.779 9.087 23.651 0.25 +6 41 108.929 27.968 0 16.261 1.814 4.035 9.997 26.815 0.25 +6 42 108.957 32.01 0 14.981 1.775 3.886 9.498 25.174 0.333 +6 43 108.951 35.986 0 15.7 1.817 4.07 10.19 27.709 0.333 +6 45 108.946 39.964 0 14.803 1.834 4.163 10.622 29.587 0.333 +6 46 109.052 44.053 0 15.35 1.769 3.842 9.285 24.258 0.333 +6 47 108.948 48.094 0 14.954 1.777 3.875 9.388 24.566 0.333 +6 48 109.013 51.913 0 15.198 1.796 3.979 9.855 26.507 0.333 +6 49 108.961 56.033 0 14.739 1.825 4.096 10.266 27.915 0.333 From 272174b0dd4e9aafa677a7570c5128d1c7928d94 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Mon, 23 Oct 2017 16:29:06 +0200 Subject: [PATCH 04/22] basic framework and preliminary assessment for mosaic reader --- biotracks/readfile.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 215f5e6..9e16a5c 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -393,6 +393,19 @@ def read(self): self._links[cmso.LINK_ID] -= 1 # CELLMIA index is 1-based +class MosaicReader(AbstractReader): + """ + User can save detected particles and tracks. The particles file can contain more objects than the tracks file, + these would then be solitary, unlinked objects. None of the files contains an object id, cross-referencing files is only possibly + by examining coordinates. (Let user convert/upload only the tracks file or the objects as well?) + Tracks file contains the same features as objects file, besides the extra particles. + According to ImageJ documentation, results can be saved as .csv, .tsv or .txt. + """ + + def read(self): + + + class TracksReader(object): """\ Generic reader that delegates to specific ones based on file extension. From c3599eb179f0a2376d5a2425770f6097778bb8e2 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Tue, 24 Oct 2017 16:15:24 +0200 Subject: [PATCH 05/22] basic ini file --- examples/Mosaic/example_1/biotracks.ini | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 examples/Mosaic/example_1/biotracks.ini diff --git a/examples/Mosaic/example_1/biotracks.ini b/examples/Mosaic/example_1/biotracks.ini new file mode 100644 index 0000000..1be0a7f --- /dev/null +++ b/examples/Mosaic/example_1/biotracks.ini @@ -0,0 +1,8 @@ +[TOP_LEVEL_INFO] +author = paola masuzzo +title = A CMSO data package representation of cell tracking data +name = cmso_tracks +author_institute = VIB +author_email = paola.masuzzo@email.com + +[TRACKING_DATA] From d21638c1581210db7cbf1a5a7c13a49e4d3043c2 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 11:59:57 +0100 Subject: [PATCH 06/22] implemented cellmia-similar reader and changed the delegator class --- biotracks/readfile.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 9e16a5c..030d724 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -302,7 +302,7 @@ def read_objects(self): cp_df.reset_index(inplace=True) for index, row in cp_df.iterrows(): objects_dict[index] = [row[self.frame], row[self.x], row[self.y]] - objects_df = pd.DataFrame( + objects_df = pd.DataFrame( [[key, value[0], value[1], value[2]] for key, value in objects_dict.items()], columns=[self.obj_id, self.frame, self.x, self.y] @@ -394,15 +394,17 @@ def read(self): class MosaicReader(AbstractReader): - """ - User can save detected particles and tracks. The particles file can contain more objects than the tracks file, - these would then be solitary, unlinked objects. None of the files contains an object id, cross-referencing files is only possibly - by examining coordinates. (Let user convert/upload only the tracks file or the objects as well?) - Tracks file contains the same features as objects file, besides the extra particles. - According to ImageJ documentation, results can be saved as .csv, .tsv or .txt. - """ + + MOSAIC_COLS = ["Trajectory", "Frame", "x", "y", "z"] def read(self): + mo_df = pd.read_csv(self.fname, usecols=self.MOSAIC_COLS) + mo_df.reset_index(inplace=True) + cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] + mo_df.columns = cols + self._objects = df.drop(cmso.LINK_ID, 1) + self._links = df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD], 1) + self._links[cmso.LINK_ID] -= 1 @@ -424,14 +426,24 @@ def __init__(self, fname, conf=None, log_level=None): self.reader = TrackMateReader( fname, conf=conf, log_level=log_level ) - elif ext == '.csv': - self.reader = CellProfilerReader( + elif ext == ('.csv' or '.tsv' or '.txt'): + #read header and delegate to correct reader + #this pandas method can read csv, tsv and txt files + df = pd.read_csv(fname, header=None sep=None, nrows=1) + trackname = df.iloc[0] + if trackname == 'ImageNumber': + self.reader = CellProfilerReader( + fname, conf=conf, log_level=log_level + ) + elif trackname == 'ID of track': + self.reader = CellmiaReader( fname, conf=conf, log_level=log_level ) - elif ext == '.txt': - self.reader = CellmiaReader( + elif trackname == 'Trajectory': + self.reader = MosaicReader( fname, conf=conf, log_level=log_level ) + elif ext == '.json': self.reader = BiotracksReader( fname, conf=conf, log_level=log_level From 4751e07cc46623a51424a98a29caf8c806ad47b9 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 15:41:54 +0100 Subject: [PATCH 07/22] Testing and fixes, add output files --- biotracks/readfile.py | 10 +- examples/Mosaic/example_1/dp/dp.json | 88 +++++++++++ examples/Mosaic/example_1/dp/links.csv | 182 +++++++++++++++++++++++ examples/Mosaic/example_1/dp/objects.csv | 182 +++++++++++++++++++++++ 4 files changed, 457 insertions(+), 5 deletions(-) create mode 100644 examples/Mosaic/example_1/dp/dp.json create mode 100644 examples/Mosaic/example_1/dp/links.csv create mode 100644 examples/Mosaic/example_1/dp/objects.csv diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 030d724..9a2eaa3 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -398,12 +398,12 @@ class MosaicReader(AbstractReader): MOSAIC_COLS = ["Trajectory", "Frame", "x", "y", "z"] def read(self): - mo_df = pd.read_csv(self.fname, usecols=self.MOSAIC_COLS) + mo_df = pd.read_csv(self.fname, sep=None, usecols=self.MOSAIC_COLS) mo_df.reset_index(inplace=True) cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] mo_df.columns = cols - self._objects = df.drop(cmso.LINK_ID, 1) - self._links = df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD], 1) + self._objects = mo_df.drop(cmso.LINK_ID, 1) + self._links = mo_df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD], 1) self._links[cmso.LINK_ID] -= 1 @@ -429,8 +429,8 @@ def __init__(self, fname, conf=None, log_level=None): elif ext == ('.csv' or '.tsv' or '.txt'): #read header and delegate to correct reader #this pandas method can read csv, tsv and txt files - df = pd.read_csv(fname, header=None sep=None, nrows=1) - trackname = df.iloc[0] + df = pd.read_csv(fname, header=None, sep=None, nrows=1) + trackname = df.iloc[0, 0] if trackname == 'ImageNumber': self.reader = CellProfilerReader( fname, conf=conf, log_level=log_level diff --git a/examples/Mosaic/example_1/dp/dp.json b/examples/Mosaic/example_1/dp/dp.json new file mode 100644 index 0000000..7e82009 --- /dev/null +++ b/examples/Mosaic/example_1/dp/dp.json @@ -0,0 +1,88 @@ +{ + "author": "paola masuzzo", + "author_email": "paola.masuzzo@email.com", + "author_institute": "VIB", + "name": "cmso_tracks", + "resources": [ + { + "name": "cmso_objects_table", + "path": "objects.csv", + "schema": { + "fields": [ + { + "constraints": { + "unique": true + }, + "description": "", + "format": "default", + "name": "cmso_object_id", + "title": "", + "type": "integer" + }, + { + "description": "", + "format": "default", + "name": "cmso_frame_id", + "title": "", + "type": "integer" + }, + { + "description": "", + "format": "default", + "name": "cmso_x_coord", + "title": "", + "type": "number" + }, + { + "description": "", + "format": "default", + "name": "cmso_y_coord", + "title": "", + "type": "number" + }, + { + "description": "", + "format": "default", + "name": "cmso_z_coord", + "title": "", + "type": "integer" + } + ], + "primaryKey": "cmso_object_id" + } + }, + { + "name": "cmso_links_table", + "path": "links.csv", + "schema": { + "fields": [ + { + "description": "", + "format": "default", + "name": "cmso_object_id", + "title": "", + "type": "integer" + }, + { + "description": "", + "format": "default", + "name": "cmso_link_id", + "title": "", + "type": "integer" + } + ], + "foreignKeys": [ + { + "fields": "cmso_object_id", + "reference": { + "datapackage": "", + "fields": "cmso_object_id", + "resource": "cmso_objects_table" + } + } + ] + } + } + ], + "title": "A CMSO data package representation of cell tracking data" +} diff --git a/examples/Mosaic/example_1/dp/links.csv b/examples/Mosaic/example_1/dp/links.csv new file mode 100644 index 0000000..0f613fb --- /dev/null +++ b/examples/Mosaic/example_1/dp/links.csv @@ -0,0 +1,182 @@ +cmso_object_id,cmso_link_id +0,0 +1,0 +2,0 +3,0 +4,0 +5,0 +6,0 +7,0 +8,0 +9,0 +10,0 +11,0 +12,0 +13,0 +14,0 +15,0 +16,0 +17,0 +18,0 +19,0 +20,0 +21,0 +22,0 +23,0 +24,0 +25,0 +26,0 +27,0 +28,0 +29,0 +30,0 +31,0 +32,0 +33,0 +34,0 +35,0 +36,0 +37,0 +38,0 +39,0 +40,0 +41,0 +42,1 +43,1 +44,1 +45,1 +46,1 +47,1 +48,1 +49,1 +50,1 +51,1 +52,1 +53,1 +54,1 +55,1 +56,1 +57,1 +58,1 +59,1 +60,1 +61,1 +62,1 +63,1 +64,1 +65,1 +66,1 +67,1 +68,1 +69,1 +70,1 +71,1 +72,1 +73,1 +74,1 +75,1 +76,1 +77,1 +78,1 +79,1 +80,1 +81,1 +82,1 +83,1 +84,1 +85,1 +86,1 +87,1 +88,1 +89,2 +90,2 +91,2 +92,2 +93,2 +94,2 +95,2 +96,2 +97,2 +98,2 +99,2 +100,2 +101,2 +102,2 +103,2 +104,2 +105,2 +106,2 +107,2 +108,2 +109,2 +110,2 +111,2 +112,2 +113,2 +114,2 +115,2 +116,2 +117,2 +118,2 +119,2 +120,2 +121,2 +122,2 +123,2 +124,2 +125,2 +126,2 +127,2 +128,2 +129,2 +130,2 +131,2 +132,2 +133,2 +134,2 +135,2 +136,2 +137,2 +138,2 +139,3 +140,3 +141,3 +142,3 +143,3 +144,3 +145,3 +146,3 +147,3 +148,3 +149,3 +150,3 +151,3 +152,3 +153,3 +154,3 +155,3 +156,3 +157,3 +158,3 +159,3 +160,4 +161,4 +162,4 +163,4 +164,4 +165,4 +166,4 +167,4 +168,4 +169,4 +170,4 +171,5 +172,5 +173,5 +174,5 +175,5 +176,5 +177,5 +178,5 +179,5 +180,5 diff --git a/examples/Mosaic/example_1/dp/objects.csv b/examples/Mosaic/example_1/dp/objects.csv new file mode 100644 index 0000000..2fb535b --- /dev/null +++ b/examples/Mosaic/example_1/dp/objects.csv @@ -0,0 +1,182 @@ +cmso_object_id,cmso_frame_id,cmso_x_coord,cmso_y_coord,cmso_z_coord +0,0,64.50399999999999,4.413,0 +1,1,64.638,6.528,0 +2,2,64.52199999999999,10.52,0 +3,3,64.093,13.027000000000001,0 +4,4,62.885,16.847,0 +5,5,60.031000000000006,19.994,0 +6,6,60.141999999999996,20.007,0 +7,7,58.068999999999996,22.073,0 +8,8,58.025,22.998,0 +9,9,62.032,25.995,0 +10,10,63.027,30.026999999999997,0 +11,11,63.09,34.013000000000005,0 +12,12,63.042,37.092,0 +13,13,63.104,39.053000000000004,0 +14,14,63.04600000000001,41.173,0 +15,15,64.536,46.881,0 +16,16,64.06,52.089,0 +17,17,64.16199999999999,55.992,0 +18,18,62.088,57.961999999999996,0 +19,19,59.918,62.928999999999995,0 +20,20,59.911,68.057,0 +21,21,60.123999999999995,72.931,0 +22,22,59.878,77.098,0 +23,23,60.003,79.0,0 +24,24,59.966,80.077,0 +25,25,60.044,80.008,0 +26,26,54.081,83.065,0 +27,27,52.02,87.071,0 +28,28,52.13,91.958,0 +29,29,51.835,93.64,0 +30,30,52.025,98.191,0 +31,31,51.997,98.962,0 +32,32,51.978,101.036,0 +33,33,52.07,102.979,0 +34,34,52.178999999999995,104.012,0 +35,35,52.123999999999995,105.012,0 +36,36,52.031000000000006,108.02600000000001,0 +37,37,52.013999999999996,108.958,0 +38,38,52.051,112.025,0 +39,39,52.012,115.05,0 +40,40,51.953,117.928,0 +41,41,51.995,121.095,0 +42,0,105.09100000000001,112.859,0 +43,1,104.902,113.101,0 +44,2,104.985,113.009,0 +45,3,104.991,112.98700000000001,0 +46,4,104.838,112.92399999999999,0 +47,5,105.09700000000001,112.92,0 +48,6,105.198,113.47200000000001,0 +49,7,105.035,112.87899999999999,0 +50,8,105.204,112.76899999999999,0 +51,9,105.087,113.139,0 +52,10,104.727,113.275,0 +53,11,105.006,112.807,0 +54,12,105.134,112.944,0 +55,13,104.836,113.288,0 +56,14,105.03,113.473,0 +57,15,105.204,112.854,0 +58,16,104.902,113.29799999999999,0 +59,19,104.88600000000001,112.839,0 +60,20,105.00399999999999,112.954,0 +61,21,105.025,112.897,0 +62,23,104.758,112.898,0 +63,24,105.027,113.059,0 +64,25,105.18700000000001,113.01799999999999,0 +65,26,105.35700000000001,112.944,0 +66,27,104.561,112.979,0 +67,28,105.197,113.117,0 +68,29,105.029,113.083,0 +69,30,104.838,112.81700000000001,0 +70,31,105.05,113.176,0 +71,32,104.91799999999999,113.09299999999999,0 +72,33,105.089,112.742,0 +73,34,104.723,112.971,0 +74,35,104.905,112.87200000000001,0 +75,36,105.023,113.19200000000001,0 +76,37,104.959,113.119,0 +77,38,105.169,112.88799999999999,0 +78,39,105.056,113.29899999999999,0 +79,40,104.79799999999999,113.054,0 +80,41,105.016,112.75399999999999,0 +81,42,104.795,113.03399999999999,0 +82,43,105.12,113.34700000000001,0 +83,44,105.18,112.897,0 +84,45,104.95100000000001,113.09899999999999,0 +85,46,105.031,112.728,0 +86,47,104.93799999999999,112.765,0 +87,48,104.595,112.726,0 +88,49,104.632,113.1,0 +89,0,116.77600000000001,116.691,0 +90,1,116.72,116.655,0 +91,2,116.835,116.512,0 +92,3,116.85,116.48200000000001,0 +93,4,116.889,116.397,0 +94,5,116.73700000000001,116.59100000000001,0 +95,6,116.788,116.491,0 +96,7,116.867,116.53299999999999,0 +97,8,116.89399999999999,116.454,0 +98,9,116.81299999999999,116.51299999999999,0 +99,10,116.679,116.345,0 +100,11,116.751,116.352,0 +101,12,116.834,116.458,0 +102,13,116.92,116.941,0 +103,14,116.844,116.561,0 +104,15,116.82600000000001,116.564,0 +105,16,116.932,116.506,0 +106,17,116.861,116.575,0 +107,18,116.726,116.443,0 +108,19,116.735,116.43700000000001,0 +109,20,116.821,116.398,0 +110,21,116.86200000000001,116.522,0 +111,22,116.791,116.559,0 +112,23,116.736,116.459,0 +113,24,116.78,116.329,0 +114,25,116.786,116.602,0 +115,26,116.8,116.554,0 +116,27,116.895,116.693,0 +117,28,116.76799999999999,116.587,0 +118,29,116.822,116.45200000000001,0 +119,30,116.815,116.432,0 +120,31,116.883,116.45,0 +121,32,116.87100000000001,116.413,0 +122,33,116.74,116.99700000000001,0 +123,34,116.78,116.49700000000001,0 +124,35,116.74,116.556,0 +125,36,116.80799999999999,116.604,0 +126,37,116.67,115.45,0 +127,38,116.698,116.491,0 +128,39,116.75,116.446,0 +129,40,116.814,116.48299999999999,0 +130,41,116.73,116.509,0 +131,42,116.805,116.626,0 +132,43,116.869,116.48,0 +133,44,116.84700000000001,116.473,0 +134,45,116.78,116.43,0 +135,46,116.906,116.662,0 +136,47,116.806,116.615,0 +137,48,116.70700000000001,116.50399999999999,0 +138,49,116.75399999999999,116.455,0 +139,9,53.016999999999996,26.112,0 +140,10,49.925,28.943,0 +141,11,49.071000000000005,30.068,0 +142,12,46.095,33.003,0 +143,13,42.907,34.818000000000005,0 +144,14,40.079,37.881,0 +145,15,36.984,42.031000000000006,0 +146,16,32.891,44.968,0 +147,17,27.984,47.056000000000004,0 +148,18,23.98,50.105,0 +149,19,17.910999999999998,47.952,0 +150,20,12.915999999999999,44.98,0 +151,21,9.961,41.062,0 +152,22,9.949,37.076,0 +153,23,9.934,32.972,0 +154,24,9.965,28.024,0 +155,25,9.95,23.002,0 +156,26,10.166,18.017,0 +157,27,14.033,15.019,0 +158,28,19.180999999999997,13.049000000000001,0 +159,29,23.125,10.96,0 +160,16,42.106,48.086000000000006,0 +161,17,41.977,52.06,0 +162,18,42.021,55.074,0 +163,19,42.169,56.986000000000004,0 +164,20,41.966,60.028,0 +165,21,42.004,63.964,0 +166,22,42.108999999999995,68.03699999999999,0 +167,23,42.015,71.977,0 +168,24,42.066,76.07600000000001,0 +169,25,44.931999999999995,79.962,0 +170,26,49.915,82.90799999999999,0 +171,39,108.86399999999999,19.074,0 +172,40,108.88600000000001,24.02,0 +173,41,108.929,27.968000000000004,0 +174,42,108.95700000000001,32.01,0 +175,43,108.95100000000001,35.986,0 +176,45,108.946,39.964,0 +177,46,109.052,44.053000000000004,0 +178,47,108.948,48.093999999999994,0 +179,48,109.01299999999999,51.913000000000004,0 +180,49,108.961,56.033,0 From 34bbc3119ac5dd870cb7a3de26b1609fb1e58f44 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 15:52:35 +0100 Subject: [PATCH 08/22] infer tracks from links --- examples/Mosaic/example_1/dp/tracks.csv | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/Mosaic/example_1/dp/tracks.csv diff --git a/examples/Mosaic/example_1/dp/tracks.csv b/examples/Mosaic/example_1/dp/tracks.csv new file mode 100644 index 0000000..dc5fd2a --- /dev/null +++ b/examples/Mosaic/example_1/dp/tracks.csv @@ -0,0 +1,7 @@ +cmso_track_id,cmso_link_id +0,0 +1,1 +2,2 +3,3 +4,4 +5,5 From 1b6b7f0dd089cd81e9e08ffad97525216750eb25 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 16:01:20 +0100 Subject: [PATCH 09/22] formatting --- biotracks/readfile.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 9a2eaa3..ec66ab7 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -44,6 +44,7 @@ class AbstractReader(metaclass=ABCMeta): """\ Common interface for all tracking data readers. """ + def __init__(self, fname, conf=None, log_level=None): """\ Set the input file name for the reader. @@ -303,10 +304,10 @@ def read_objects(self): for index, row in cp_df.iterrows(): objects_dict[index] = [row[self.frame], row[self.x], row[self.y]] objects_df = pd.DataFrame( - [[key, value[0], value[1], value[2]] - for key, value in objects_dict.items()], - columns=[self.obj_id, self.frame, self.x, self.y] - ) + [[key, value[0], value[1], value[2]] + for key, value in objects_dict.items()], + columns=[self.obj_id, self.frame, self.x, self.y] + ) objects_df.columns = [ cmso.OBJECT_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD ] @@ -394,24 +395,26 @@ def read(self): class MosaicReader(AbstractReader): - + MOSAIC_COLS = ["Trajectory", "Frame", "x", "y", "z"] def read(self): mo_df = pd.read_csv(self.fname, sep=None, usecols=self.MOSAIC_COLS) mo_df.reset_index(inplace=True) - cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] + cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, + cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] mo_df.columns = cols self._objects = mo_df.drop(cmso.LINK_ID, 1) - self._links = mo_df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD], 1) + self._links = mo_df.drop( + [cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD], 1) self._links[cmso.LINK_ID] -= 1 - class TracksReader(object): """\ Generic reader that delegates to specific ones based on file extension. """ + def __init__(self, fname, conf=None, log_level=None): """\ Initialize and store a specific reader based on filename extension. @@ -427,23 +430,23 @@ def __init__(self, fname, conf=None, log_level=None): fname, conf=conf, log_level=log_level ) elif ext == ('.csv' or '.tsv' or '.txt'): - #read header and delegate to correct reader - #this pandas method can read csv, tsv and txt files + # read header and delegate to correct reader + # this pandas method can read csv, tsv and txt files df = pd.read_csv(fname, header=None, sep=None, nrows=1) trackname = df.iloc[0, 0] if trackname == 'ImageNumber': self.reader = CellProfilerReader( - fname, conf=conf, log_level=log_level - ) + fname, conf=conf, log_level=log_level + ) elif trackname == 'ID of track': self.reader = CellmiaReader( - fname, conf=conf, log_level=log_level - ) + fname, conf=conf, log_level=log_level + ) elif trackname == 'Trajectory': self.reader = MosaicReader( - fname, conf=conf, log_level=log_level - ) - + fname, conf=conf, log_level=log_level + ) + elif ext == '.json': self.reader = BiotracksReader( fname, conf=conf, log_level=log_level From fbcb3f0ff37b81c163521f2d9b931bf44d2298bc Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 16:18:27 +0100 Subject: [PATCH 10/22] extension check fix --- biotracks/readfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index ec66ab7..bffef02 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -429,7 +429,7 @@ def __init__(self, fname, conf=None, log_level=None): self.reader = TrackMateReader( fname, conf=conf, log_level=log_level ) - elif ext == ('.csv' or '.tsv' or '.txt'): + elif ext in ['.csv', '.tsv', '.txt']: # read header and delegate to correct reader # this pandas method can read csv, tsv and txt files df = pd.read_csv(fname, header=None, sep=None, nrows=1) From 57258347b23d617ddaadc8badb71aaa0ce7cfdc9 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Mon, 23 Oct 2017 16:12:14 +0200 Subject: [PATCH 11/22] readme for mosaic example --- examples/Mosaic/readme.md | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/Mosaic/readme.md diff --git a/examples/Mosaic/readme.md b/examples/Mosaic/readme.md new file mode 100644 index 0000000..19169b9 --- /dev/null +++ b/examples/Mosaic/readme.md @@ -0,0 +1,41 @@ +## Mosaic example + +The example in the *Mosaic* directory was generated using the [MosaicSuite plugin](http://mosaic.mpi-cbg.de/?q=downloads/imageJ) for ImageJ/Fiji. + +Version used: `MosaicSuite-1.0.8`. + +### Example 1 +The dataset used in this example is the same used in the [TrackMate](../TrackMate) and other examples. The images were both detected and tracked using the Mosaic Particle Tracker tool. + +#### The test dataset +The test dataset used can be uploaded in ImageJ: + +`File ▶ Open Samples ▶ Tracks for TrackMate (807K)` + +You can then open and run the Mosaic plugin selecting: + +`Plugins ▶ Mosaic ▶ Particle Tracker 2D/3D ` + +Alternatively, you can download the data from this [link](http://fiji.sc/samples/FakeTracks.tif). + +#### Settings to reproduce the two examples +To reproduce the example in this directory, you need to choose the following settings + +- Detection settings: + - Kernel radius: 5 + - Cutoff radius: 0.01 + - Percentile: 0.4 +- Tracking settings: + - Displacement: 10.0 + - Linkrange: 3 + +Once you run the tracking, you can select **All Trajectories to Table**, which opens an ImageJ table that you can save to disk. + + +#### Running the data_package library +Move to the example directory and run the data package creation script: + +``` +cd examples/Mosaic/example_1 +python ../../../scripts/create_dpkg.py mosaic_tracks.csv +``` \ No newline at end of file From c8e878a0376f5af00c044e2a60e5870ae6eb593e Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Mon, 23 Oct 2017 16:12:55 +0200 Subject: [PATCH 12/22] add tracking data --- examples/Mosaic/example_1/mosaic_tracks.csv | 182 ++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 examples/Mosaic/example_1/mosaic_tracks.csv diff --git a/examples/Mosaic/example_1/mosaic_tracks.csv b/examples/Mosaic/example_1/mosaic_tracks.csv new file mode 100644 index 0000000..18fbef4 --- /dev/null +++ b/examples/Mosaic/example_1/mosaic_tracks.csv @@ -0,0 +1,182 @@ +Trajectory Frame x y z m0 m1 m2 m3 m4 NPscore +1 0 64.504 4.413 0 11.746 1.663 3.4 7.696 18.783 0.333 +1 1 64.638 6.528 0 10.934 1.639 3.302 7.369 17.752 0.333 +1 2 64.522 10.52 0 10.444 1.63 3.273 7.276 17.459 0.333 +1 3 64.093 13.027 0 14.807 1.767 3.837 9.277 24.26 0.333 +1 4 62.885 16.847 0 14.428 1.806 3.989 9.8 26.008 0.333 +1 5 60.031 19.994 0 14.954 1.779 3.909 9.612 25.697 0.333 +1 6 60.142 20.007 0 14.659 1.778 3.886 9.454 24.873 0.333 +1 7 58.069 22.073 0 14.164 1.771 3.856 9.344 24.496 0.333 +1 8 58.025 22.998 0 15.31 1.787 3.923 9.584 25.308 0.333 +1 9 62.032 25.995 0 13.826 1.783 3.931 9.693 25.956 0.25 +1 10 63.027 30.027 0 13.886 1.786 3.929 9.645 25.676 0.25 +1 11 63.09 34.013 0 15.525 1.804 4.006 9.928 26.677 0.252 +1 12 63.042 37.092 0 14.123 1.768 3.858 9.407 24.926 0.25 +1 13 63.104 39.053 0 15.205 1.782 3.898 9.484 24.961 0.25 +1 14 63.046 41.173 0 15.616 1.783 3.904 9.527 25.178 0.25 +1 15 64.536 46.881 0 19.476 1.831 4.094 10.165 27.23 0.25 +1 16 64.06 52.089 0 15.24 1.778 3.877 9.397 24.616 0.201 +1 17 64.162 55.992 0 16.172 1.763 3.831 9.31 24.603 0.261 +1 18 62.088 57.962 0 15.439 1.808 4.005 9.872 26.321 0.25 +1 19 59.918 62.929 0 13.484 1.755 3.791 9.124 23.779 0.2 +1 20 59.911 68.057 0 15.189 1.793 3.987 9.973 27.272 0.2 +1 21 60.124 72.931 0 15.765 1.796 3.94 9.596 25.215 0.26 +1 22 59.878 77.098 0 15.291 1.774 3.865 9.365 24.54 0.25 +1 23 60.003 79 0 16.177 1.843 4.188 10.659 29.508 0.2 +1 24 59.966 80.077 0 14.801 1.76 3.817 9.24 24.261 0.2 +1 25 60.044 80.008 0 15.731 1.785 3.934 9.7 26.008 0.2 +1 26 54.081 83.065 0 16.769 2.329 7.058 24.859 96.608 0.2 +1 27 52.02 87.071 0 14.658 1.774 3.875 9.439 24.905 0.25 +1 28 52.13 91.958 0 15.864 1.796 3.952 9.668 25.552 0.25 +1 29 51.835 93.64 0 12.296 1.689 3.507 8.09 20.171 0.25 +1 30 52.025 98.191 0 14.826 1.775 3.87 9.39 24.657 0.333 +1 31 51.997 98.962 0 15.765 1.781 3.91 9.584 25.492 0.333 +1 32 51.978 101.036 0 14.238 1.789 3.938 9.667 25.701 0.333 +1 33 52.07 102.979 0 15.758 1.822 4.099 10.326 28.288 0.333 +1 34 52.179 104.012 0 14.222 1.772 3.884 9.567 25.771 0.333 +1 35 52.124 105.012 0 14.447 1.778 3.883 9.441 24.826 0.333 +1 36 52.031 108.026 0 14.669 1.781 3.904 9.547 25.306 0.333 +1 37 52.014 108.958 0 15.217 1.783 3.925 9.679 25.993 0.333 +1 38 52.051 112.025 0 14.828 1.779 3.881 9.418 24.7 0.333 +1 39 52.012 115.05 0 15.767 1.81 4.033 10.045 27.166 0.25 +1 40 51.953 117.928 0 14.331 1.791 3.947 9.708 25.886 0.25 +1 41 51.995 121.095 0 15.511 1.785 3.919 9.583 25.368 0.25 +2 0 105.091 112.859 0 5.759 1.661 3.437 7.973 20.17 0.333 +2 1 104.902 113.101 0 4.679 1.684 3.566 8.552 22.634 0.333 +2 2 104.985 113.009 0 4.019 1.617 3.275 7.434 18.393 0.333 +2 3 104.991 112.987 0 5.414 1.701 3.611 8.607 22.379 0.333 +2 4 104.838 112.924 0 5.338 1.735 3.747 9.089 24.063 0.333 +2 5 105.097 112.92 0 6.31 1.712 3.641 8.698 22.722 0.333 +2 6 105.198 113.472 0 5.633 1.658 3.394 7.736 19.111 0.333 +2 7 105.035 112.879 0 4.369 1.705 3.687 9.16 25.545 0.333 +2 8 105.204 112.769 0 4.913 1.615 3.255 7.381 18.436 0.333 +2 9 105.087 113.139 0 4.673 1.631 3.286 7.352 17.792 0.25 +2 10 104.727 113.275 0 4.662 1.722 3.707 9.027 24.215 0.25 +2 11 105.006 112.807 0 5.694 1.747 3.808 9.355 25.194 0.25 +2 12 105.134 112.944 0 6.2 1.719 3.694 8.969 23.945 0.25 +2 13 104.836 113.288 0 5.49 1.642 3.337 7.552 18.54 0.25 +2 14 105.03 113.473 0 4.485 1.624 3.309 7.595 19.149 0.25 +2 15 105.204 112.854 0 5.812 1.61 3.212 7.136 17.195 0.25 +2 16 104.902 113.298 0 5.152 1.73 3.744 9.145 24.512 0.2 +2 19 104.886 112.839 0 5.784 1.688 3.539 8.311 21.272 0.2 +2 20 105.004 112.954 0 4.511 1.655 3.422 7.929 20.024 0.2 +2 21 105.025 112.897 0 5.183 1.588 3.144 6.953 16.742 0.2 +2 23 104.758 112.898 0 5.173 1.664 3.444 7.972 20.097 0.2 +2 24 105.027 113.059 0 5.097 1.739 3.774 9.21 24.545 0.2 +2 25 105.187 113.018 0 6.126 1.707 3.62 8.608 22.311 0.2 +2 26 105.357 112.944 0 5.616 1.72 3.66 8.695 22.407 0.2 +2 27 104.561 112.979 0 4.366 1.622 3.363 8.065 22.04 0.25 +2 28 105.197 113.117 0 4.6 1.657 3.412 7.847 19.606 0.25 +2 29 105.029 113.083 0 4.711 1.743 3.777 9.18 24.305 0.25 +2 30 104.838 112.817 0 4.842 1.6 3.155 6.895 16.286 0.333 +2 31 105.05 113.176 0 5.324 1.694 3.574 8.44 21.684 0.333 +2 32 104.918 113.093 0 4.81 1.612 3.247 7.333 18.08 0.333 +2 33 105.089 112.742 0 4.521 1.713 3.631 8.597 22.129 0.333 +2 34 104.723 112.971 0 4.695 1.686 3.548 8.414 21.904 0.333 +2 35 104.905 112.872 0 4.42 1.656 3.473 8.37 22.835 0.333 +2 36 105.023 113.192 0 4.967 1.707 3.648 8.765 22.987 0.333 +2 37 104.959 113.119 0 5.148 1.717 3.673 8.84 23.297 0.333 +2 38 105.169 112.888 0 4.49 1.644 3.365 7.734 19.455 0.333 +2 39 105.056 113.299 0 4.135 1.657 3.417 7.869 19.695 0.25 +2 40 104.798 113.054 0 4.794 1.59 3.138 6.902 16.495 0.25 +2 41 105.016 112.754 0 4.249 1.708 3.644 8.755 23.029 0.25 +2 42 104.795 113.034 0 3.894 1.775 4.058 10.793 32.394 0.333 +2 43 105.12 113.347 0 5.461 1.619 3.237 7.184 17.232 0.333 +2 44 105.18 112.897 0 5.148 1.655 3.412 7.874 19.816 0.143 +2 45 104.951 113.099 0 5.031 1.623 3.28 7.414 18.269 0.333 +2 46 105.031 112.728 0 5.191 1.696 3.573 8.419 21.602 0.333 +2 47 104.938 112.765 0 5.787 1.67 3.462 7.999 20.036 0.333 +2 48 104.595 112.726 0 4.821 1.728 3.714 8.993 23.931 0.333 +2 49 104.632 113.1 0 4.731 1.832 4.336 11.977 37.385 0.333 +3 0 116.776 116.691 0 12.079 2.353 6.845 22.421 79.66 0.333 +3 1 116.72 116.655 0 12.515 2.24 6.203 19.353 65.651 0.333 +3 2 116.835 116.512 0 12.604 2.3 6.526 20.844 72.268 0.333 +3 3 116.85 116.482 0 12.305 2.236 6.199 19.431 66.41 0.333 +3 4 116.889 116.397 0 11.648 2.256 6.275 19.64 66.749 0.333 +3 5 116.737 116.591 0 12.504 2.373 6.983 23.145 83.203 0.333 +3 6 116.788 116.491 0 12.299 2.247 6.245 19.579 66.812 0.333 +3 7 116.867 116.533 0 12.44 2.341 6.762 21.976 77.414 0.333 +3 8 116.894 116.454 0 12.402 2.256 6.274 19.664 67.078 0.333 +3 9 116.813 116.513 0 12.509 2.392 7.083 23.635 85.53 0.25 +3 10 116.679 116.345 0 12.003 2.24 6.204 19.375 65.844 0.25 +3 11 116.751 116.352 0 11.923 2.266 6.39 20.414 71.164 0.25 +3 12 116.834 116.458 0 12.756 2.336 6.749 21.982 77.736 0.25 +3 13 116.92 116.941 0 12.654 2.347 6.836 22.542 81.062 0.25 +3 14 116.844 116.561 0 12.538 2.349 6.822 22.303 79.08 0.25 +3 15 116.826 116.564 0 12.644 2.308 6.586 21.216 74.372 0.25 +3 16 116.932 116.506 0 12.051 2.317 6.651 21.516 75.568 0.2 +3 17 116.861 116.575 0 12.96 2.324 6.674 21.618 76.174 0.25 +3 18 116.726 116.443 0 12.215 2.342 6.792 22.212 78.867 0.25 +3 19 116.735 116.437 0 12.18 2.247 6.255 19.687 67.576 0.2 +3 20 116.821 116.398 0 11.784 2.293 6.532 21.012 73.487 0.2 +3 21 116.862 116.522 0 12.715 2.348 6.815 22.291 79.162 0.2 +3 22 116.791 116.559 0 12.175 2.29 6.493 20.759 72.117 0.25 +3 23 116.736 116.459 0 12.427 2.318 6.643 21.468 75.425 0.2 +3 24 116.78 116.329 0 11.653 2.269 6.399 20.413 70.941 0.2 +3 25 116.786 116.602 0 12.541 2.279 6.365 19.926 67.506 0.2 +3 26 116.8 116.554 0 11.956 2.296 6.524 20.893 72.696 0.2 +3 27 116.895 116.693 0 12.876 2.324 6.669 21.529 75.369 0.25 +3 28 116.768 116.587 0 12.622 2.262 6.318 19.914 68.347 0.25 +3 29 116.822 116.452 0 12.242 2.308 6.639 21.609 76.607 0.25 +3 30 116.815 116.432 0 11.85 2.329 6.686 21.577 75.453 0.333 +3 31 116.883 116.45 0 12.223 2.246 6.224 19.406 65.708 0.333 +3 32 116.871 116.413 0 12.314 2.369 6.957 23.046 82.888 0.333 +3 33 116.74 116.997 0 12.98 2.353 6.911 23 83.404 0.333 +3 34 116.78 116.497 0 12.444 2.274 6.383 20.18 69.322 0.333 +3 35 116.74 116.556 0 12.344 2.322 6.647 21.392 74.639 0.333 +3 36 116.808 116.604 0 12.779 2.426 7.25 24.333 88.364 0.333 +3 37 116.67 115.45 0 9.859 1.915 4.57 12.351 36.611 0.333 +3 38 116.698 116.491 0 11.934 2.298 6.522 20.815 72.056 0.333 +3 39 116.75 116.446 0 12.13 2.276 6.423 20.48 71.1 0.25 +3 40 116.814 116.483 0 12.939 2.329 6.731 21.955 77.842 0.25 +3 41 116.73 116.509 0 12.313 2.303 6.578 21.248 74.745 0.25 +3 42 116.805 116.626 0 12.819 2.328 6.705 21.783 76.897 0.333 +3 43 116.869 116.48 0 12.845 2.316 6.641 21.493 75.646 0.333 +3 44 116.847 116.473 0 12.554 2.309 6.588 21.177 73.904 0.143 +3 45 116.78 116.43 0 12.376 2.336 6.762 22.081 78.321 0.333 +3 46 116.906 116.662 0 12.937 2.374 6.953 22.888 81.626 0.333 +3 47 116.806 116.615 0 12.909 2.346 6.782 22.054 77.733 0.333 +3 48 116.707 116.504 0 12.313 2.315 6.625 21.375 74.939 0.333 +3 49 116.754 116.455 0 12.193 2.284 6.437 20.408 70.212 0.333 +4 9 53.017 26.112 0 14.457 1.767 3.848 9.34 24.562 0.25 +4 10 49.925 28.943 0 14.642 1.77 3.846 9.296 24.29 0.25 +4 11 49.071 30.068 0 15.83 1.807 3.997 9.827 26.091 0.252 +4 12 46.095 33.003 0 14.915 1.792 3.962 9.791 26.288 0.25 +4 13 42.907 34.818 0 15.617 1.799 3.968 9.74 25.852 0.25 +4 14 40.079 37.881 0 15.036 1.78 3.883 9.407 24.61 0.25 +4 15 36.984 42.031 0 14.329 1.828 4.152 10.639 29.876 0.25 +4 16 32.891 44.968 0 14.918 1.768 3.83 9.216 23.947 0.204 +4 17 27.984 47.056 0 13.477 1.774 3.883 9.487 25.133 0.25 +4 18 23.98 50.105 0 14.183 1.766 3.836 9.285 24.332 0.25 +4 19 17.911 47.952 0 14.307 1.753 3.775 9.048 23.46 0.2 +4 20 12.916 44.98 0 14.427 1.8 3.991 9.887 26.573 0.2 +4 21 9.961 41.062 0 15.811 1.816 4.089 10.351 28.63 0.26 +4 22 9.949 37.076 0 14.195 1.805 4.024 10.05 27.321 0.25 +4 23 9.934 32.972 0 14.264 1.774 3.879 9.468 25.066 0.268 +4 24 9.965 28.024 0 13.851 1.796 3.973 9.816 26.306 0.2 +4 25 9.95 23.002 0 15.194 1.826 4.115 10.394 28.575 0.202 +4 26 10.166 18.017 0 15.259 1.795 3.957 9.71 25.786 0.2 +4 27 14.033 15.019 0 15.525 1.813 4.071 10.271 28.272 0.25 +4 28 19.181 13.049 0 14.897 1.777 3.905 9.618 25.793 0.25 +4 29 23.125 10.96 0 15.139 1.795 3.974 9.847 26.548 0.25 +5 16 42.106 48.086 0 14.64 1.75 3.757 8.971 23.166 0.203 +5 17 41.977 52.06 0 16.18 1.821 4.079 10.205 27.698 0.261 +5 18 42.021 55.074 0 14.713 1.776 3.891 9.518 25.257 0.25 +5 19 42.169 56.986 0 14.632 1.778 3.903 9.586 25.594 0.2 +5 20 41.966 60.028 0 15.652 1.796 3.966 9.767 26.071 0.2 +5 21 42.004 63.964 0 15.437 1.801 3.995 9.9 26.625 0.201 +5 22 42.109 68.037 0 14.626 1.805 4.001 9.886 26.471 0.25 +5 23 42.015 71.977 0 14.131 1.76 3.817 9.23 24.186 0.268 +5 24 42.066 76.076 0 15.323 1.775 3.873 9.412 24.753 0.2 +5 25 44.932 79.962 0 14.981 1.781 3.9 9.516 25.135 0.202 +5 26 49.915 82.908 0 16.501 2.229 6.528 22.47 86.189 0.2 +6 39 108.864 19.074 0 14.914 1.753 3.772 9.017 23.299 0.25 +6 40 108.886 24.02 0 13.964 1.751 3.779 9.087 23.651 0.25 +6 41 108.929 27.968 0 16.261 1.814 4.035 9.997 26.815 0.25 +6 42 108.957 32.01 0 14.981 1.775 3.886 9.498 25.174 0.333 +6 43 108.951 35.986 0 15.7 1.817 4.07 10.19 27.709 0.333 +6 45 108.946 39.964 0 14.803 1.834 4.163 10.622 29.587 0.333 +6 46 109.052 44.053 0 15.35 1.769 3.842 9.285 24.258 0.333 +6 47 108.948 48.094 0 14.954 1.777 3.875 9.388 24.566 0.333 +6 48 109.013 51.913 0 15.198 1.796 3.979 9.855 26.507 0.333 +6 49 108.961 56.033 0 14.739 1.825 4.096 10.266 27.915 0.333 From 50fd785e978bb7b108923cfe082807e9bddb784d Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Mon, 23 Oct 2017 16:29:06 +0200 Subject: [PATCH 13/22] basic framework and preliminary assessment for mosaic reader --- biotracks/readfile.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 215f5e6..9e16a5c 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -393,6 +393,19 @@ def read(self): self._links[cmso.LINK_ID] -= 1 # CELLMIA index is 1-based +class MosaicReader(AbstractReader): + """ + User can save detected particles and tracks. The particles file can contain more objects than the tracks file, + these would then be solitary, unlinked objects. None of the files contains an object id, cross-referencing files is only possibly + by examining coordinates. (Let user convert/upload only the tracks file or the objects as well?) + Tracks file contains the same features as objects file, besides the extra particles. + According to ImageJ documentation, results can be saved as .csv, .tsv or .txt. + """ + + def read(self): + + + class TracksReader(object): """\ Generic reader that delegates to specific ones based on file extension. From f01e070e6fecdd8d4facc0dbb3b82b83403edc90 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Tue, 24 Oct 2017 16:15:24 +0200 Subject: [PATCH 14/22] basic ini file --- examples/Mosaic/example_1/biotracks.ini | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 examples/Mosaic/example_1/biotracks.ini diff --git a/examples/Mosaic/example_1/biotracks.ini b/examples/Mosaic/example_1/biotracks.ini new file mode 100644 index 0000000..1be0a7f --- /dev/null +++ b/examples/Mosaic/example_1/biotracks.ini @@ -0,0 +1,8 @@ +[TOP_LEVEL_INFO] +author = paola masuzzo +title = A CMSO data package representation of cell tracking data +name = cmso_tracks +author_institute = VIB +author_email = paola.masuzzo@email.com + +[TRACKING_DATA] From d3aa98bce0c5346c06f84a233c2a161da107335d Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 11:59:57 +0100 Subject: [PATCH 15/22] implemented cellmia-similar reader and changed the delegator class --- biotracks/readfile.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 9e16a5c..030d724 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -302,7 +302,7 @@ def read_objects(self): cp_df.reset_index(inplace=True) for index, row in cp_df.iterrows(): objects_dict[index] = [row[self.frame], row[self.x], row[self.y]] - objects_df = pd.DataFrame( + objects_df = pd.DataFrame( [[key, value[0], value[1], value[2]] for key, value in objects_dict.items()], columns=[self.obj_id, self.frame, self.x, self.y] @@ -394,15 +394,17 @@ def read(self): class MosaicReader(AbstractReader): - """ - User can save detected particles and tracks. The particles file can contain more objects than the tracks file, - these would then be solitary, unlinked objects. None of the files contains an object id, cross-referencing files is only possibly - by examining coordinates. (Let user convert/upload only the tracks file or the objects as well?) - Tracks file contains the same features as objects file, besides the extra particles. - According to ImageJ documentation, results can be saved as .csv, .tsv or .txt. - """ + + MOSAIC_COLS = ["Trajectory", "Frame", "x", "y", "z"] def read(self): + mo_df = pd.read_csv(self.fname, usecols=self.MOSAIC_COLS) + mo_df.reset_index(inplace=True) + cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] + mo_df.columns = cols + self._objects = df.drop(cmso.LINK_ID, 1) + self._links = df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD], 1) + self._links[cmso.LINK_ID] -= 1 @@ -424,14 +426,24 @@ def __init__(self, fname, conf=None, log_level=None): self.reader = TrackMateReader( fname, conf=conf, log_level=log_level ) - elif ext == '.csv': - self.reader = CellProfilerReader( + elif ext == ('.csv' or '.tsv' or '.txt'): + #read header and delegate to correct reader + #this pandas method can read csv, tsv and txt files + df = pd.read_csv(fname, header=None sep=None, nrows=1) + trackname = df.iloc[0] + if trackname == 'ImageNumber': + self.reader = CellProfilerReader( + fname, conf=conf, log_level=log_level + ) + elif trackname == 'ID of track': + self.reader = CellmiaReader( fname, conf=conf, log_level=log_level ) - elif ext == '.txt': - self.reader = CellmiaReader( + elif trackname == 'Trajectory': + self.reader = MosaicReader( fname, conf=conf, log_level=log_level ) + elif ext == '.json': self.reader = BiotracksReader( fname, conf=conf, log_level=log_level From 4e03094d5e6ed03deeffecd1cd0cec97ee8b2dcd Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 15:41:54 +0100 Subject: [PATCH 16/22] Testing and fixes, add output files --- biotracks/readfile.py | 10 +- examples/Mosaic/example_1/dp/dp.json | 88 +++++++++++ examples/Mosaic/example_1/dp/links.csv | 182 +++++++++++++++++++++++ examples/Mosaic/example_1/dp/objects.csv | 182 +++++++++++++++++++++++ 4 files changed, 457 insertions(+), 5 deletions(-) create mode 100644 examples/Mosaic/example_1/dp/dp.json create mode 100644 examples/Mosaic/example_1/dp/links.csv create mode 100644 examples/Mosaic/example_1/dp/objects.csv diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 030d724..9a2eaa3 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -398,12 +398,12 @@ class MosaicReader(AbstractReader): MOSAIC_COLS = ["Trajectory", "Frame", "x", "y", "z"] def read(self): - mo_df = pd.read_csv(self.fname, usecols=self.MOSAIC_COLS) + mo_df = pd.read_csv(self.fname, sep=None, usecols=self.MOSAIC_COLS) mo_df.reset_index(inplace=True) cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] mo_df.columns = cols - self._objects = df.drop(cmso.LINK_ID, 1) - self._links = df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD], 1) + self._objects = mo_df.drop(cmso.LINK_ID, 1) + self._links = mo_df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD], 1) self._links[cmso.LINK_ID] -= 1 @@ -429,8 +429,8 @@ def __init__(self, fname, conf=None, log_level=None): elif ext == ('.csv' or '.tsv' or '.txt'): #read header and delegate to correct reader #this pandas method can read csv, tsv and txt files - df = pd.read_csv(fname, header=None sep=None, nrows=1) - trackname = df.iloc[0] + df = pd.read_csv(fname, header=None, sep=None, nrows=1) + trackname = df.iloc[0, 0] if trackname == 'ImageNumber': self.reader = CellProfilerReader( fname, conf=conf, log_level=log_level diff --git a/examples/Mosaic/example_1/dp/dp.json b/examples/Mosaic/example_1/dp/dp.json new file mode 100644 index 0000000..7e82009 --- /dev/null +++ b/examples/Mosaic/example_1/dp/dp.json @@ -0,0 +1,88 @@ +{ + "author": "paola masuzzo", + "author_email": "paola.masuzzo@email.com", + "author_institute": "VIB", + "name": "cmso_tracks", + "resources": [ + { + "name": "cmso_objects_table", + "path": "objects.csv", + "schema": { + "fields": [ + { + "constraints": { + "unique": true + }, + "description": "", + "format": "default", + "name": "cmso_object_id", + "title": "", + "type": "integer" + }, + { + "description": "", + "format": "default", + "name": "cmso_frame_id", + "title": "", + "type": "integer" + }, + { + "description": "", + "format": "default", + "name": "cmso_x_coord", + "title": "", + "type": "number" + }, + { + "description": "", + "format": "default", + "name": "cmso_y_coord", + "title": "", + "type": "number" + }, + { + "description": "", + "format": "default", + "name": "cmso_z_coord", + "title": "", + "type": "integer" + } + ], + "primaryKey": "cmso_object_id" + } + }, + { + "name": "cmso_links_table", + "path": "links.csv", + "schema": { + "fields": [ + { + "description": "", + "format": "default", + "name": "cmso_object_id", + "title": "", + "type": "integer" + }, + { + "description": "", + "format": "default", + "name": "cmso_link_id", + "title": "", + "type": "integer" + } + ], + "foreignKeys": [ + { + "fields": "cmso_object_id", + "reference": { + "datapackage": "", + "fields": "cmso_object_id", + "resource": "cmso_objects_table" + } + } + ] + } + } + ], + "title": "A CMSO data package representation of cell tracking data" +} diff --git a/examples/Mosaic/example_1/dp/links.csv b/examples/Mosaic/example_1/dp/links.csv new file mode 100644 index 0000000..0f613fb --- /dev/null +++ b/examples/Mosaic/example_1/dp/links.csv @@ -0,0 +1,182 @@ +cmso_object_id,cmso_link_id +0,0 +1,0 +2,0 +3,0 +4,0 +5,0 +6,0 +7,0 +8,0 +9,0 +10,0 +11,0 +12,0 +13,0 +14,0 +15,0 +16,0 +17,0 +18,0 +19,0 +20,0 +21,0 +22,0 +23,0 +24,0 +25,0 +26,0 +27,0 +28,0 +29,0 +30,0 +31,0 +32,0 +33,0 +34,0 +35,0 +36,0 +37,0 +38,0 +39,0 +40,0 +41,0 +42,1 +43,1 +44,1 +45,1 +46,1 +47,1 +48,1 +49,1 +50,1 +51,1 +52,1 +53,1 +54,1 +55,1 +56,1 +57,1 +58,1 +59,1 +60,1 +61,1 +62,1 +63,1 +64,1 +65,1 +66,1 +67,1 +68,1 +69,1 +70,1 +71,1 +72,1 +73,1 +74,1 +75,1 +76,1 +77,1 +78,1 +79,1 +80,1 +81,1 +82,1 +83,1 +84,1 +85,1 +86,1 +87,1 +88,1 +89,2 +90,2 +91,2 +92,2 +93,2 +94,2 +95,2 +96,2 +97,2 +98,2 +99,2 +100,2 +101,2 +102,2 +103,2 +104,2 +105,2 +106,2 +107,2 +108,2 +109,2 +110,2 +111,2 +112,2 +113,2 +114,2 +115,2 +116,2 +117,2 +118,2 +119,2 +120,2 +121,2 +122,2 +123,2 +124,2 +125,2 +126,2 +127,2 +128,2 +129,2 +130,2 +131,2 +132,2 +133,2 +134,2 +135,2 +136,2 +137,2 +138,2 +139,3 +140,3 +141,3 +142,3 +143,3 +144,3 +145,3 +146,3 +147,3 +148,3 +149,3 +150,3 +151,3 +152,3 +153,3 +154,3 +155,3 +156,3 +157,3 +158,3 +159,3 +160,4 +161,4 +162,4 +163,4 +164,4 +165,4 +166,4 +167,4 +168,4 +169,4 +170,4 +171,5 +172,5 +173,5 +174,5 +175,5 +176,5 +177,5 +178,5 +179,5 +180,5 diff --git a/examples/Mosaic/example_1/dp/objects.csv b/examples/Mosaic/example_1/dp/objects.csv new file mode 100644 index 0000000..2fb535b --- /dev/null +++ b/examples/Mosaic/example_1/dp/objects.csv @@ -0,0 +1,182 @@ +cmso_object_id,cmso_frame_id,cmso_x_coord,cmso_y_coord,cmso_z_coord +0,0,64.50399999999999,4.413,0 +1,1,64.638,6.528,0 +2,2,64.52199999999999,10.52,0 +3,3,64.093,13.027000000000001,0 +4,4,62.885,16.847,0 +5,5,60.031000000000006,19.994,0 +6,6,60.141999999999996,20.007,0 +7,7,58.068999999999996,22.073,0 +8,8,58.025,22.998,0 +9,9,62.032,25.995,0 +10,10,63.027,30.026999999999997,0 +11,11,63.09,34.013000000000005,0 +12,12,63.042,37.092,0 +13,13,63.104,39.053000000000004,0 +14,14,63.04600000000001,41.173,0 +15,15,64.536,46.881,0 +16,16,64.06,52.089,0 +17,17,64.16199999999999,55.992,0 +18,18,62.088,57.961999999999996,0 +19,19,59.918,62.928999999999995,0 +20,20,59.911,68.057,0 +21,21,60.123999999999995,72.931,0 +22,22,59.878,77.098,0 +23,23,60.003,79.0,0 +24,24,59.966,80.077,0 +25,25,60.044,80.008,0 +26,26,54.081,83.065,0 +27,27,52.02,87.071,0 +28,28,52.13,91.958,0 +29,29,51.835,93.64,0 +30,30,52.025,98.191,0 +31,31,51.997,98.962,0 +32,32,51.978,101.036,0 +33,33,52.07,102.979,0 +34,34,52.178999999999995,104.012,0 +35,35,52.123999999999995,105.012,0 +36,36,52.031000000000006,108.02600000000001,0 +37,37,52.013999999999996,108.958,0 +38,38,52.051,112.025,0 +39,39,52.012,115.05,0 +40,40,51.953,117.928,0 +41,41,51.995,121.095,0 +42,0,105.09100000000001,112.859,0 +43,1,104.902,113.101,0 +44,2,104.985,113.009,0 +45,3,104.991,112.98700000000001,0 +46,4,104.838,112.92399999999999,0 +47,5,105.09700000000001,112.92,0 +48,6,105.198,113.47200000000001,0 +49,7,105.035,112.87899999999999,0 +50,8,105.204,112.76899999999999,0 +51,9,105.087,113.139,0 +52,10,104.727,113.275,0 +53,11,105.006,112.807,0 +54,12,105.134,112.944,0 +55,13,104.836,113.288,0 +56,14,105.03,113.473,0 +57,15,105.204,112.854,0 +58,16,104.902,113.29799999999999,0 +59,19,104.88600000000001,112.839,0 +60,20,105.00399999999999,112.954,0 +61,21,105.025,112.897,0 +62,23,104.758,112.898,0 +63,24,105.027,113.059,0 +64,25,105.18700000000001,113.01799999999999,0 +65,26,105.35700000000001,112.944,0 +66,27,104.561,112.979,0 +67,28,105.197,113.117,0 +68,29,105.029,113.083,0 +69,30,104.838,112.81700000000001,0 +70,31,105.05,113.176,0 +71,32,104.91799999999999,113.09299999999999,0 +72,33,105.089,112.742,0 +73,34,104.723,112.971,0 +74,35,104.905,112.87200000000001,0 +75,36,105.023,113.19200000000001,0 +76,37,104.959,113.119,0 +77,38,105.169,112.88799999999999,0 +78,39,105.056,113.29899999999999,0 +79,40,104.79799999999999,113.054,0 +80,41,105.016,112.75399999999999,0 +81,42,104.795,113.03399999999999,0 +82,43,105.12,113.34700000000001,0 +83,44,105.18,112.897,0 +84,45,104.95100000000001,113.09899999999999,0 +85,46,105.031,112.728,0 +86,47,104.93799999999999,112.765,0 +87,48,104.595,112.726,0 +88,49,104.632,113.1,0 +89,0,116.77600000000001,116.691,0 +90,1,116.72,116.655,0 +91,2,116.835,116.512,0 +92,3,116.85,116.48200000000001,0 +93,4,116.889,116.397,0 +94,5,116.73700000000001,116.59100000000001,0 +95,6,116.788,116.491,0 +96,7,116.867,116.53299999999999,0 +97,8,116.89399999999999,116.454,0 +98,9,116.81299999999999,116.51299999999999,0 +99,10,116.679,116.345,0 +100,11,116.751,116.352,0 +101,12,116.834,116.458,0 +102,13,116.92,116.941,0 +103,14,116.844,116.561,0 +104,15,116.82600000000001,116.564,0 +105,16,116.932,116.506,0 +106,17,116.861,116.575,0 +107,18,116.726,116.443,0 +108,19,116.735,116.43700000000001,0 +109,20,116.821,116.398,0 +110,21,116.86200000000001,116.522,0 +111,22,116.791,116.559,0 +112,23,116.736,116.459,0 +113,24,116.78,116.329,0 +114,25,116.786,116.602,0 +115,26,116.8,116.554,0 +116,27,116.895,116.693,0 +117,28,116.76799999999999,116.587,0 +118,29,116.822,116.45200000000001,0 +119,30,116.815,116.432,0 +120,31,116.883,116.45,0 +121,32,116.87100000000001,116.413,0 +122,33,116.74,116.99700000000001,0 +123,34,116.78,116.49700000000001,0 +124,35,116.74,116.556,0 +125,36,116.80799999999999,116.604,0 +126,37,116.67,115.45,0 +127,38,116.698,116.491,0 +128,39,116.75,116.446,0 +129,40,116.814,116.48299999999999,0 +130,41,116.73,116.509,0 +131,42,116.805,116.626,0 +132,43,116.869,116.48,0 +133,44,116.84700000000001,116.473,0 +134,45,116.78,116.43,0 +135,46,116.906,116.662,0 +136,47,116.806,116.615,0 +137,48,116.70700000000001,116.50399999999999,0 +138,49,116.75399999999999,116.455,0 +139,9,53.016999999999996,26.112,0 +140,10,49.925,28.943,0 +141,11,49.071000000000005,30.068,0 +142,12,46.095,33.003,0 +143,13,42.907,34.818000000000005,0 +144,14,40.079,37.881,0 +145,15,36.984,42.031000000000006,0 +146,16,32.891,44.968,0 +147,17,27.984,47.056000000000004,0 +148,18,23.98,50.105,0 +149,19,17.910999999999998,47.952,0 +150,20,12.915999999999999,44.98,0 +151,21,9.961,41.062,0 +152,22,9.949,37.076,0 +153,23,9.934,32.972,0 +154,24,9.965,28.024,0 +155,25,9.95,23.002,0 +156,26,10.166,18.017,0 +157,27,14.033,15.019,0 +158,28,19.180999999999997,13.049000000000001,0 +159,29,23.125,10.96,0 +160,16,42.106,48.086000000000006,0 +161,17,41.977,52.06,0 +162,18,42.021,55.074,0 +163,19,42.169,56.986000000000004,0 +164,20,41.966,60.028,0 +165,21,42.004,63.964,0 +166,22,42.108999999999995,68.03699999999999,0 +167,23,42.015,71.977,0 +168,24,42.066,76.07600000000001,0 +169,25,44.931999999999995,79.962,0 +170,26,49.915,82.90799999999999,0 +171,39,108.86399999999999,19.074,0 +172,40,108.88600000000001,24.02,0 +173,41,108.929,27.968000000000004,0 +174,42,108.95700000000001,32.01,0 +175,43,108.95100000000001,35.986,0 +176,45,108.946,39.964,0 +177,46,109.052,44.053000000000004,0 +178,47,108.948,48.093999999999994,0 +179,48,109.01299999999999,51.913000000000004,0 +180,49,108.961,56.033,0 From 5341419ffcbbde1f46e1e726e82206cd0cd1340b Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 15:52:35 +0100 Subject: [PATCH 17/22] infer tracks from links --- examples/Mosaic/example_1/dp/tracks.csv | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/Mosaic/example_1/dp/tracks.csv diff --git a/examples/Mosaic/example_1/dp/tracks.csv b/examples/Mosaic/example_1/dp/tracks.csv new file mode 100644 index 0000000..dc5fd2a --- /dev/null +++ b/examples/Mosaic/example_1/dp/tracks.csv @@ -0,0 +1,7 @@ +cmso_track_id,cmso_link_id +0,0 +1,1 +2,2 +3,3 +4,4 +5,5 From a4ee280e1c11d3266dc4bd4ac1bc92eae6e9add1 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 16:01:20 +0100 Subject: [PATCH 18/22] formatting --- biotracks/readfile.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index 9a2eaa3..ec66ab7 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -44,6 +44,7 @@ class AbstractReader(metaclass=ABCMeta): """\ Common interface for all tracking data readers. """ + def __init__(self, fname, conf=None, log_level=None): """\ Set the input file name for the reader. @@ -303,10 +304,10 @@ def read_objects(self): for index, row in cp_df.iterrows(): objects_dict[index] = [row[self.frame], row[self.x], row[self.y]] objects_df = pd.DataFrame( - [[key, value[0], value[1], value[2]] - for key, value in objects_dict.items()], - columns=[self.obj_id, self.frame, self.x, self.y] - ) + [[key, value[0], value[1], value[2]] + for key, value in objects_dict.items()], + columns=[self.obj_id, self.frame, self.x, self.y] + ) objects_df.columns = [ cmso.OBJECT_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD ] @@ -394,24 +395,26 @@ def read(self): class MosaicReader(AbstractReader): - + MOSAIC_COLS = ["Trajectory", "Frame", "x", "y", "z"] def read(self): mo_df = pd.read_csv(self.fname, sep=None, usecols=self.MOSAIC_COLS) mo_df.reset_index(inplace=True) - cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] + cols = [cmso.OBJECT_ID, cmso.LINK_ID, cmso.FRAME_ID, + cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD] mo_df.columns = cols self._objects = mo_df.drop(cmso.LINK_ID, 1) - self._links = mo_df.drop([cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD], 1) + self._links = mo_df.drop( + [cmso.FRAME_ID, cmso.X_COORD, cmso.Y_COORD, cmso.Z_COORD], 1) self._links[cmso.LINK_ID] -= 1 - class TracksReader(object): """\ Generic reader that delegates to specific ones based on file extension. """ + def __init__(self, fname, conf=None, log_level=None): """\ Initialize and store a specific reader based on filename extension. @@ -427,23 +430,23 @@ def __init__(self, fname, conf=None, log_level=None): fname, conf=conf, log_level=log_level ) elif ext == ('.csv' or '.tsv' or '.txt'): - #read header and delegate to correct reader - #this pandas method can read csv, tsv and txt files + # read header and delegate to correct reader + # this pandas method can read csv, tsv and txt files df = pd.read_csv(fname, header=None, sep=None, nrows=1) trackname = df.iloc[0, 0] if trackname == 'ImageNumber': self.reader = CellProfilerReader( - fname, conf=conf, log_level=log_level - ) + fname, conf=conf, log_level=log_level + ) elif trackname == 'ID of track': self.reader = CellmiaReader( - fname, conf=conf, log_level=log_level - ) + fname, conf=conf, log_level=log_level + ) elif trackname == 'Trajectory': self.reader = MosaicReader( - fname, conf=conf, log_level=log_level - ) - + fname, conf=conf, log_level=log_level + ) + elif ext == '.json': self.reader = BiotracksReader( fname, conf=conf, log_level=log_level From cc1ad20244951772f63cb14fa93bf34e15774fc5 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 22 Nov 2017 16:18:27 +0100 Subject: [PATCH 19/22] extension check fix --- biotracks/readfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biotracks/readfile.py b/biotracks/readfile.py index ec66ab7..bffef02 100644 --- a/biotracks/readfile.py +++ b/biotracks/readfile.py @@ -429,7 +429,7 @@ def __init__(self, fname, conf=None, log_level=None): self.reader = TrackMateReader( fname, conf=conf, log_level=log_level ) - elif ext == ('.csv' or '.tsv' or '.txt'): + elif ext in ['.csv', '.tsv', '.txt']: # read header and delegate to correct reader # this pandas method can read csv, tsv and txt files df = pd.read_csv(fname, header=None, sep=None, nrows=1) From 825f92320fb5d65d035f29f7cba3ab8ed8731baf Mon Sep 17 00:00:00 2001 From: Alejandra Gonzalez-Beltran Date: Wed, 31 Jan 2018 14:36:49 +0000 Subject: [PATCH 20/22] Rename readme.md to Readme.md --- examples/Mosaic/{readme.md => Readme.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/Mosaic/{readme.md => Readme.md} (99%) diff --git a/examples/Mosaic/readme.md b/examples/Mosaic/Readme.md similarity index 99% rename from examples/Mosaic/readme.md rename to examples/Mosaic/Readme.md index 19169b9..5f18708 100644 --- a/examples/Mosaic/readme.md +++ b/examples/Mosaic/Readme.md @@ -38,4 +38,4 @@ Move to the example directory and run the data package creation script: ``` cd examples/Mosaic/example_1 python ../../../scripts/create_dpkg.py mosaic_tracks.csv -``` \ No newline at end of file +``` From 261512deb6aed1bbe6c4119e95bf2dde86e95c88 Mon Sep 17 00:00:00 2001 From: Gwendolien Sergeant Date: Wed, 31 Jan 2018 16:05:07 +0100 Subject: [PATCH 21/22] Add tests for Mosaic reader --- tests/common.py | 1 + tests/test_createdp.py | 3 +++ tests/test_pushtopandas.py | 3 +++ tests/test_readfile.py | 3 +++ 4 files changed, 10 insertions(+) diff --git a/tests/common.py b/tests/common.py index 99968cc..87ea7d9 100644 --- a/tests/common.py +++ b/tests/common.py @@ -54,4 +54,5 @@ def get_track_dict(df, link_id, track_id): 'CELLMIA': ['example_1', '0001_mode1_z000_f000_tracking.txt'], 'TrackMate': ['example_1', 'FakeTracks.xml'], 'CellProfiler': ['example_1', 'output', 'bloboverlap15_spots.csv'], + 'Mosaic': ['example_1', 'mosaic_tracks.csv'], } diff --git a/tests/test_createdp.py b/tests/test_createdp.py index 0eea6c9..ba99b23 100644 --- a/tests/test_createdp.py +++ b/tests/test_createdp.py @@ -64,6 +64,9 @@ def test_cellprofiler(self, data): def test_trackmate(self, data): self.__check_dps(data('TrackMate')) + def test_mosaic(self, data): + self.__check_dps(data('Mosaic')) + def __check_dps(self, d): dp = createdp.create(d['reader'], d['dp_dir']) assert dp.to_dict() == d['dp'].to_dict() diff --git a/tests/test_pushtopandas.py b/tests/test_pushtopandas.py index 2cedc1d..0381a34 100644 --- a/tests/test_pushtopandas.py +++ b/tests/test_pushtopandas.py @@ -65,6 +65,9 @@ def test_cellprofiler(self, data): def test_trackmate(self, data): self.__check_dicts(data('TrackMate')) + def test_mosaic(self, data): + self.__check_dicts(data('Mosaic')) + def __check_dicts(self, d): obj_id = cmso.OBJECT_ID link_id = cmso.LINK_ID diff --git a/tests/test_readfile.py b/tests/test_readfile.py index 911a0cf..f5496f9 100644 --- a/tests/test_readfile.py +++ b/tests/test_readfile.py @@ -75,6 +75,9 @@ def test_trackmate(self, data): d['reader'].read() assert top_level[cmso.SPACE_UNIT] == spatial_unit + def test_mosaic(seld, data): + self.__check_dicts(data('Mosaic')) + def __check_dicts(self, d): for reader in (d['reader'], d['bt_reader']): for name in 'objects', 'links': From 60988910b054f9d730e1e6684f86a2788f954287 Mon Sep 17 00:00:00 2001 From: Alejandra Gonzalez-Beltran Date: Wed, 31 Jan 2018 16:12:00 +0000 Subject: [PATCH 22/22] Fixing typo related to self variable --- tests/test_readfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_readfile.py b/tests/test_readfile.py index f5496f9..30bb9b2 100644 --- a/tests/test_readfile.py +++ b/tests/test_readfile.py @@ -75,7 +75,7 @@ def test_trackmate(self, data): d['reader'].read() assert top_level[cmso.SPACE_UNIT] == spatial_unit - def test_mosaic(seld, data): + def test_mosaic(self, data): self.__check_dicts(data('Mosaic')) def __check_dicts(self, d):