zhaokg / Rbeast

Bayesian Change-Point Detection and Time Series Decomposition
236 stars 38 forks source link

Beast with Octave 8.2 #11

Open mariolino007 opened 1 year ago

mariolino007 commented 1 year ago

Hello, I would like to try your software with Windows 11 x64 + Octave 8.2, it doesn't work, does it need to be recompiled ? Can you make a script for recompilation ?

thanks

Mario Rossi

zhaokg commented 1 year ago

Like said in my email, yes, it needs recompilation. I got the mex file compiled for Octave, but the matlab script (.m files) needs some changes too because matlab and octave treat strings slightly differently.

zhaokg commented 1 year ago

Done! I added the octave-specific mex file ( Rbeast.mex under the matlab folder). I did some quick tests on my side and at least it is workable, thought there could be some unforeseen bugs given the imperfect compabibility between Octave and Matlab. In the command line of Octave, install using the following command:

beastPath = 'C:\beast\'  
eval( webread('http://b.link/rbeast') )  

Please do let me know if it is working appropriately on your end.

mariolino007 commented 1 year ago

thanks for the implentation, it seems to me that the calculation works correctly, the plotbeast(o) command in the various examples instead goes into error :

plotbeast(o) error: mx_el_eq: nonconformant arguments (op1 is 1x37, op2 is 1x2) error: called from plotbeast at line 80 column 10

thanks

PS could you also post the ".m" file for self compilation in octave ?

zhaokg commented 1 year ago

My best guess is that you just downloaded Rbeast.mex but kept the old plotbeast.m file, which would give you the error at line 80. For the octave version, I not just recompiled the mex file but also changed the plotbeast. m file (agian, because Matlab and Octave are not completely compatible when coming to string processing).. Please re-install the program and download all the files using "eval( webread('http://b.link/rbeast') ) ".

Below is what I did for getting the Rbeast.mex. I didn't use the mkoctfile or mex command because I couldn't figure out how to provide multiple files as inputs. Instead, I directly used the following command lines in a cmd console, assusming that you have all the source files (.c and .h) downloaded from the Source github folder to a local folder F:/src/.

gcc -c -fPIC  -pthread -O2 -DM_RELEASE -DO_INTERFACE -I"C:\Program Files\GNU Octave\Octave-8.2.0\mingw64\include\octave-8.2.0\octave"     f:/src/*.c 

g++  -pthread -fopenmp -g -O2  -o Rbeast.mex *.o  -shared -LC:\PROGRA~1\GNUOCT~1\OCTAVE~1.0\mingw64\lib\octave\8.2.0   -loctinterp -loctave    -Wl,--export-all-symbols    -lkernel32 -lgdi32 -luser32   
mariolino007 commented 1 year ago

the plot works you are right !!! Thanks With the compliaction I have a problem from the command line....

C:\Program Files\GNU Octave\Octave-8.2.0_large\mingw64\bin>gcc -c -fPIC -pthread -O2 -DM_RELEASE -DO_INTERFACE -I "C:\Program Files\GNU Octave\Octave-8.2.0_large\mingw64\include\octave-8.2.0_large\ingw64\bin>gcc -c -fPIC -pthread -O2 -DM_RELEASE -DO_INTERFACE -I "C:\Program Files\GNU Octave\Octave-8.2.0_large\mingw64\include\octave-8.2.0_large\ingw64\bin>" P:/rbeast/Rbeast-master/Source/*.c

cc1.exe: fatal error: P:/rbeast/Rbeast-master/Source/*.c: Invalid argument compilation terminated.

In octave I generally saw using a file like "compile_rbest_octave.m" that used commands like:

mex [options] file ...

https://docs.octave.org/v4.2.0/Getting-Started-with-Mex_002dFiles.html

thanks

zhaokg commented 1 year ago

Yes, I had the same problem when using Octave's default gcc. THat is Octave's own gcc. Seems like that it does't support a wildcard ".c". LIke I said last time, the "mkoctfile " or "mex" (the two are the same) does't accept ".c", either. But I managed to find a solution ("https://stackoverflow.com/questions/76672265/in-octave-how-to-compile-a-mex-file-from-multiple-c-c-source-files").

Now the file "rbeast_mex_compile.m" should be working for Octave in Windows, at least for the several machines I tested.

Thanks a lot.

mariolino007 commented 1 year ago

thanks, I used "rbeast_mex_compile.m" it generated a mex file of very different size than your repository, as soon as octave calls it for any example octave crashes. Patience I use your mex file which works very well. I ask you again for help attached there is a link to a wetrasnsfer inside there is a dataset dataset_time(sec)_vs_value_at_time.mat I would like to analyze it with your program, it is absolutely irregular and unseasonal, the first column represents the time in seconds, the second column represents the value at that exact time. Now I would like to find all the "coordinates" of all the significant changes in the data somewhat like in the attached jpg. thank you for your attention

https://we.tl/t-Qop4YAUhB5

mariolino007 commented 1 year ago

I ask you again for help attached there is a link to a wetrasnsfer inside there is a dataset dataset_time(sec)_vs_value_at_time.mat I would like to analyze it with your program, it is absolutely irregular and unseasonal, the first column represents the time in seconds, the second column represents the value at that exact time. Now I would like to find all the "coordinates" of all the significant changes in the data somewhat like in the attached jpg. thank you for your attention

Link

https://we.tl/t-Qop4YAUhB5

Il giorno gio 13 lug 2023 alle ore 20:52 zhaokg @.***> ha scritto:

Yes, I had the same problem when using Octave's default gcc. THat is Octave's own gcc. Seems like that it does't support a wildcard ".c". LIke I said last time, the "mkoctfile " or "mex" (the two are the same) does't accept ".c", either. But I managed to find a solution (" https://stackoverflow.com/questions/76672265/in-octave-how-to-compile-a-mex-file-from-multiple-c-c-source-files ").

Now the file "rbeast_mex_compile.m" should be working for Octave in Windows, at least for the several machines I tested.

Thanks a lot.

— Reply to this email directly, view it on GitHub https://github.com/zhaokg/Rbeast/issues/11#issuecomment-1634735039, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQRUVSGSNYGAGMUSPZTIODLXQA7XBANCNFSM6AAAAAA2AOCMEM . You are receiving this because you authored the thread.Message ID: @.***>

zhaokg commented 1 year ago

Dear mariolino007:

Thanks for the follow-up question. Sorry for not responding earlier because I have been out of town and was not on top of my emails/messages. Below is a quick test on your sample dataset:

load('_dataset_time(sec)_vs_value_at_time.mat')
t=mat(:,1)
y=mat(:,2)
plot(t,y);

o = beast_irreg(y, 'time',t,'season','none', 'tseg.min;',20, 'tcp.minmax',[0,20]);
plotbeast(o)

The most important two parameters are (1) tseg.min, which specifies the minium segment length in the unit of data points (tseg.min=20 means that two neigboring changepointa are separated apart by at least 20 data points), and (2) tcp.minmax, the min and max number of changepoints allowed to segment the 1D signal. You can try to pick up the best values of these parameters via trials-and-errors.