Author Topic: PJSR: Script VaryParams to execute a process varying a parameter  (Read 15256 times)

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
VaryParams executes a process varying a parameter (see attached image). It can save the results to files (for example for use by Blink) or as previews.
This is mostly useful with process modifying the source view or generating a single view (as ACDNR, StarMask, ...).
Process as DBE should be configured to update the source view (the original view will not be modified, this
will be done on a copy).

To use it, download the zip file, create a process icon, select the view and execute VaryParams.js

REQUIRES THE VERSION 1.7.6.793 (at least)

[EDITED (Jan 5, 2013)
Version-1.2 attached (combined script in 1 file)
The full project sources is hosted at https://bitbucket.org/bitli/varyparams
]

Have a nice week-end,
-- bitli

« Last Edit: 2013 January 05 09:46:18 by bitli »

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com

good idea!
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Josh Lake

  • PixInsight Old Hand
  • ****
  • Posts: 424
Whoa, this changes everything!  :D

I agree, this is a great idea and could provide a way to systematically and carefully proceed with each step of processing. If used in conjunction with image analysis tools, one could optimize a path to a 'best' image given a specific set of data (artistic considerations aside).

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Hello,
Version 0.2 has been attached to the first topic. It has significant enhancements. It works much better with processes generating multiple windows, support array parameters, copy masks when required, save and restore settings and generate a log of the results.

The sources include a few test scripts that are not required for normal operations. They may be executed in a test workspace. The test workspace with the sources is also available at http://endor.uv.es//data/public/d2aacbf623f007952a19e598d550a959.php?lang=en (due to size constraints).

Here is the log of an example runnning an Integration varying the parameter linearFitHigh:

Generated 4 files in C:/Users/bitli/AppData/Local/Temp:
   #  linearFitHigh - file
   1:           1.5 - C:/Users/bitli/AppData/Local/Temp/integration_1.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_low_1.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_high_1.fits
   2:             2 - C:/Users/bitli/AppData/Local/Temp/integration_2.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_low_2.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_high_2.fits
   3:           2.5 - C:/Users/bitli/AppData/Local/Temp/integration_3.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_low_3.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_high_3.fits
   4:             3 - C:/Users/bitli/AppData/Local/Temp/integration_4.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_low_4.fits
                    - C:/Users/bitli/AppData/Local/Temp/rejection_high_4.fits
You may load them in Blink from the directory 'C:/Users/bitli/AppData/Local/Temp'

-- bitli


Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #4 on: 2012 September 02 02:10:51 »
The version 1.0 has been posted in the first message of this thread.
It has minor enhancements and some bug corrections. 
It is now distributed as a single source file, so it is simpler to install.
All the source files, test files and test projects are available at https://bitbucket.org/bitli/varyparams.
Clear skies
-- bitli

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #5 on: 2012 September 04 04:22:25 »
GREAT IDEA !! Will be a good combination with eg a deconvolution process  ;)

Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline Philippe B.

  • PixInsight Old Hand
  • ****
  • Posts: 399
    • CIEL AUSTRAL
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #6 on: 2012 September 06 02:12:49 »
MERCIIIIIIIIIII !!

It is what you saw me in May at Besançon  8)

Offline oldwexi

  • PixInsight Guru
  • ****
  • Posts: 627
    • Astronomy Pages G.W.
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #7 on: 2012 September 06 07:06:38 »
Thanks Bitli!
A great idea and help!

Gerald

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #8 on: 2012 September 06 07:31:08 »
Hmm, I tried it today without success. I tried to run LocalHistorgramEqualization on a View, I saved the process on the desktop, opened the script and configured it as per the attached. The results are below (BTW what ACDNR has to do with it ? )  :


processTypeDescription 
                 name: ACDNR
          unsupported: false
   mayExecuteGlobally: true
     mayExecuteOnView: true
      mayUpdateSource: true
   mayCreateNewWindow: true
Execute process 'Process02' on view : LRGB_clone not masked, with parameter: amount = 0.5

LocalHistogramEqualization: Processing view: LRGB_clone
Writing swap files...
166.07 MB/s
Extracting CIE L* component: 100%
CLAHE: 100%
Importing CIE L* component: 100%
168.9 s
Writing swap files...
176.45 MB/s
Reading swap files...
752.86 MB/s
ERROR: This process modifies the source window, please select 'Update source image' in process mode, modifications undone
** VaryParams: Interrupting execution 1 due to error in last process, look at the log.
VaryParams terminated

Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #9 on: 2012 September 06 08:17:30 »
Hello,

I tried on my machine with one difference and it worked (although I do not know why it logs ACDNR as the process name, I need to check, this may be a bug). The result is like:

Code: [Select]
Generated 2 windows from view light_BINNING_1 with main views:
   #  amount - window main view
   1:    0.5 - light_BINNING_1_Process01_1
   2:      1 - light_BINNING_1_Process01_2

The trick is to select Update source image in the field Type of process.
I guess the label is not clear. The type of the process is not what you want to do (create new images), but what the process is doing. LocalHistorgramEqualization is a process that updates the image, in opposition of to say StarMask that creates a new image.  VaryParams does not know if the process will modify the image or update in place (it needs to know to make the copies at the proper stage).

In all cases VaryParam will not modify the source image.  If it detects that the process modified the image, it reverts the modification and log the message you have seen:
Code: [Select]
ERROR: This process modifies the source window, please select 'Update source image' in process mode, modifications undone
If you try again with the setting mentionned it should work. If not inform me.

Greetings
-- bitli


Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #10 on: 2012 September 06 09:32:53 »
Quote
VaryParams does not know if the process will modify the image or update in place (it needs to know to make the copies at the proper stage).

You can know that in advance. The following method of the ProcessInstance object:

Boolean ProcessInstance.isHistoryUpdater( View view )

returns true if the instance will modify the specified view when executed. You can call this method before calling executeOn( view ) to decide if a working duplicate is necessary.

By the way, this script is very nice and original. As soon as I have some time I'd like to try it out. Do you think it is ready for the 1.8 release (end of September - beginning of October)? Keep up the great work!
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #11 on: 2012 September 06 11:04:38 »
I start to thing that having you answering the questions is more convenient than reading documentation  ;)

Very useful information, I added the isHistorySelector and it seems that there is a single choice in the few processes I checked. This will remove the most confusing aspect of the script. I will complete this for the next version.

I have added the PI open source copyright, feel free to use it as you see fit. I have used it for a while with no major problem. Some processes crash if you give them totally wrong values (I guess they hope that the GUI validated the values), but in practice this does not happen for the parameters I use.

The full source is at https://bitbucket.org/bitli/varyparams. The page has a 'zip' download link, so you can easily download the whole project without installing Mercurial. The projects includes alo test scripts, a small test workspace and the script to create the release. You can load the workspace and execute the automatic test script, that should give you a good confidence that it works on 1.8 (or not). In my opinion it should be ready, but it would be nice if some user can tests it and provide feedback.

-- bitli



Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #12 on: 2012 September 06 12:13:23 »
Tested as you said and it works.
Sure Juan's addition will make it more clear (you will be amazed how much information this man can pass from a single question  ;) )

BTW, ACDNR is in line 229:

Code: [Select]
new Vp_ProcessTypeDescription("ACDNR")
and a suggestion, please give new Views a more descriptive Title, eg instead of my_LRGB_Process01, my_LRGB_Process01_1, my_LRGB_Process01_2 etc, how about my_LRGB_Process01_Amount05, my_LRGB_Process01_Amount06, my_LRGB_Process01_Amount07, ie put the parameter name and the parameter value in the Title ? (or maybe in the filename ?)

Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #13 on: 2012 September 06 13:05:43 »
Thanks,
Yes the lines with ACDNR are completly wrong, it is a left over on an old stuff.  I will remove this. The selection of 'process type' will be removed.  I also have an help page in the next version.

Finally your idea of giving a more meaningful name is very good. I had the same  :). It is just a little bit more complicated that it looks, because the parameters must form a valid file name and PI id and the ids must be unique.  For the time being I tried to make a nice table printed on the console so you can match the value and the image relatively easily.

But I will think of this again and try to come to a way to rename the images/files.

-- bitli

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: PJSR: Script VaryParams to execute a process varying a parameter
« Reply #14 on: 2012 September 20 09:06:55 »
Version 1.1 has been attached to the first post.
The main enhancement is hat it guesses the type of the process itself.
It also includes a HELP page and show the source view on top of the dialog.
Currently it does not support processes that only create new images as files, as CosmeticCorrection.

-- bitli