fdschneider / caspr

Cellular Automata for Spatial Pressure in R
MIT License
4 stars 0 forks source link

Function for fractal dimensions #4

Closed fdschneider closed 9 years ago

fdschneider commented 9 years ago

measuring perimeter to area ratio

function input:

An object of class landscape, i.e. a list x with

x$dim <- c(width, height)
x$cells <- c("+", "+", "0", .... )
fdschneider commented 9 years ago

Comparing the functions for patch counting I found the following:

However, that last one does not cope with periodic boundaries.

SabihaMajumder commented 9 years ago

Hi.. Thanks for your email. Thats's really super ! We will take a look.

Thanks, Sumithra & Sabiha

On Fri, Jun 19, 2015 at 4:27 PM, Florian Schneider <notifications@github.com

wrote:

Comparing the functions for patch counting I found the following:

  • my own function for patch labelling, written entirely in R, is too slow.
  • the package you were calling 'EBImage' is very complicated to install. I just did not succed in Ubuntu. Calling it as a dependency might be even more tedious. Thats why I tend to adopt:
  • Sonias code in the spatial_warnings package, which calls 'SDMTools' instead, which is providing a the ConnCompLabel() and PatchStat() functions that return everything we need and more: patch size, patch perimeter, ratio of the two, fractal dimensions index, shape index, core area index.

— Reply to this email directly or view it on GitHub https://github.com/fdschneider/caspr/issues/4#issuecomment-113530748.

ssumithra commented 9 years ago

Hi Florian,

If I understand how this thing works correctly, the ConnCompLabel assumes a neighbourhood of 8 and not 4 while labelling the patches? And it doesn't account for periodic boundary conditions? Should we modify and work that into Sonia's code?

Cheers, Sumithra

On 19 June 2015 at 17:09, SabihaMajumder notifications@github.com wrote:

Hi.. Thanks for your email. Thats's really super ! We will take a look.

Thanks, Sumithra & Sabiha

On Fri, Jun 19, 2015 at 4:27 PM, Florian Schneider < notifications@github.com

wrote:

Comparing the functions for patch counting I found the following:

  • my own function for patch labelling, written entirely in R, is too slow.
  • the package you were calling 'EBImage' is very complicated to install. I just did not succed in Ubuntu. Calling it as a dependency might be even more tedious. Thats why I tend to adopt:
  • Sonias code in the spatial_warnings package, which calls 'SDMTools' instead, which is providing a the ConnCompLabel() and PatchStat() functions that return everything we need and more: patch size, patch perimeter, ratio of the two, fractal dimensions index, shape index, core area index.

— Reply to this email directly or view it on GitHub https://github.com/fdschneider/caspr/issues/4#issuecomment-113530748.

— Reply to this email directly or view it on GitHub https://github.com/fdschneider/caspr/issues/4#issuecomment-113543780.

fdschneider commented 9 years ago

Not sure what's easiest. For now I returned to my own function, which is slow but does periodic boundaries, and then apply the PatchStat() function on the output matrix. Not sure how that one handles the breaks around the Torus, but it produces results.

The alternative function that uses ConnCompLabel() is still in the code as labels0(). But I confirm it uses 8-cell from looking at plots. If we can't make it assume 4-cell neighborhood this is not an option.

ssumithra commented 9 years ago

Hi,

You are using R version 3.2 right? Try typing the following in the R console -

install.packages("fftwtools") source("http://bioconductor.org/biocLite.R") biocLite() bioclite("EBImage") require("EBImage")

If this works, bwlabel should work without a glitch. Just tested on Sabiha's ubuntu comp.

On 19 June 2015 at 18:45, Florian Schneider notifications@github.com wrote:

Not sure what's easiest. For now I returned to my own function, which is slow but does periodic boundaries, and then apply the PatchStat() function on the output matrix. Not sure how that one handles the breaks around the Torus, but it produces results.

The alternative function that uses ConnCompLabel() is still in the code as labels0(). But I confirm it uses 8-cell from looking at plots. If we can't make it assume 4-cell neighborhood this is not an option.

— Reply to this email directly or view it on GitHub https://github.com/fdschneider/caspr/issues/4#issuecomment-113570884.

fdschneider commented 9 years ago

So on Ubuntu: Yes, R is up to date. No. does not work in my set-up. I get

Warning messages:
1: In install.packages(pkgs = doing, lib = lib, ...) :
  installation of package ‘tiff’ had non-zero exit status
2: In install.packages(pkgs = doing, lib = lib, ...) :
  installation of package ‘fftwtools’ had non-zero exit status
3: In install.packages(pkgs = doing, lib = lib, ...) :
  installation of package ‘EBImage’ had non-zero exit status

and the package is not available. It seems I am not able to install the tiff package, which causes problems downstream. I'll try to figure out why, but it is not obvious.

fdschneider commented 9 years ago

In Windows it works after installing

devtools::install_github("Bioconductor-mirror/BiocGenerics")
devtools::install_github("Bioconductor-mirror/EBImage")

Note: I had to disable plotting and writing output to a file.

fdschneider commented 9 years ago

Alright: your lbl() function is 30times as fast than my label(). I need to check that they produce equal results. But it's output needs to be transformed into a matrix containing factorial values.

fdschneider commented 9 years ago

Issues #15 about how to import non-CRAN packages and #13 on problems during install. The fractal indicators are to be solved at fdschneider/spatial_warnings#3