Module:Analyse des macrophages méthode 1

From DAAP
Jump to navigation Jump to search

Documentation for this module may be created at Module:Analyse des macrophages méthode 1/doc

--[[
-- Debug console

 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'test' ,
 args = { 
	iri = 'http://example.com/test',
['Id'] = '1',
['Script pretreatment matlab'] = 'file://192.168.1.13/backup/DEV1-PC/test/script1.m',
['Script spectral matrix generation matlab'] = 'file://192.168.1.13/backup/DEV1-PC/test/script2.m',
['Script automatic'] = 'true',
Matrix = 'file://192.168.1.13/backup/DEV1-PC/test/matric.md2',
Measures = 
'file://192.168.1.13/backup/DEV1-PC/test/truc1.spc, '..
'file://192.168.1.13/backup/DEV1-PC/test/truc2.spc, '..
'file://192.168.1.13/backup/DEV1-PC/test/truc3.spc, '..
'file://192.168.1.13/backup/DEV1-PC/test/truc4.spc, '..
'file://192.168.1.13/backup/DEV1-PC/test/truc5.spc'
    }
}
mw.log(p.Spectrum( newFrame ) )
---------------------
 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'test' ,
 args = { 
	iri = 'http://example.com/test',
['Id'] = '1',
['Script pretreatment matlab'] = 'file://192.168.1.13/backup/DEV1-PC/test/script1.m',
['Script spectral matrix generation matlab'] = 'file://192.168.1.13/backup/DEV1-PC/test/script2.m',
['Script automatic'] = 'true',
Matrix = 'file://192.168.1.13/backup/DEV1-PC/test/matric.md2',
Measure = 'file://192.168.1.13/backup/DEV1-PC/test/truc1.spc '
    }
}
mw.log(p.SpectrumImage( newFrame ) )

---------------------
 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'test' ,
 args = { 
	iri = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Module:Analyse_des_macrophages_méthode_1',
Date = '20170206',
Medium = 'STD',
['Slide id'] = '1',
['Nb cell'] = '15'
    }
}
mw.log(p.Slide( newFrame ) )
---------------------
 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'test' ,
 args = { 
	iri = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Analyse_des_macrophages_Campagne_1_:_2017/SlideInCampaignS',
Date = '20170206',
Medium = 'STD',
Slide = '1',
['Cell ID'] = '1'
    }
}
mw.log(p.addJ774InSlide( newFrame ) )
---------------------
 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'test' ,
 args = { 
	iri = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Analyse_des_macrophages_Campagne_1_:_2017/SlideInCampaignS',
Date = '20170206',
Medium = 'STD',
Slide = '1',
['Cell ID'] = '1',
['Position ID '] = '1'
    }
}
mw.log(p.addMeasureInJ774Core( newFrame ) )
---------------------
 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'test' ,
 args = { 
	iri = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Analyse_des_macrophages_Campagne_1_:_2017/SlideInCampaignS',
Date = '20170206',
Medium = 'STD',
Slide = '1',
['Cell ID'] = '1',
['Position ID '] = '1'
    }
}
mw.log(p.addMeasureInJ774Cyto( newFrame ) )
]]
local p = {}

function GetFileName(url)
  return url:match("^.+/(.+)$")
end

function GetFileExtension(url)
  return url:match("^.+(%..+)$")
end

function GetCampaignIri(url)
  return url:match("^(.+)/SlideInCampaign.+$")
end

function p.Spectrum(f)
	local capiunto = require 'capiunto'
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   -- local urlFolder = 'file:///z:/'
   -- local iriFolder = 'file:///filer.ups.u-psud.fr/archivagesciences/'
   local dateFormat = "d M Y"
    
    --prefix
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local daap = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Individual'
   local geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
   local vcard = 'http://www.w3.org/2006/vcard/ns#'
   local xsd = 'http://www.w3.org/2001/XMLSchema#'

 -- save data 
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
   local campaign =  linkedwiki.new(subject)
   local spectrum = nil


    local filesDestination= campaign:getValue(daapp..'filesFinalDestination')

mw.log(campaign:addPropertyWithIri(rdf..'type',project..'SpectrumCampaign'))
local result = ''
local spectrumIri = ''

if not linkedwiki.isEmpty(f.args.Id) then
	spectrumIri =  subject..'/Spectrum'..f.args.Id
	
   	mw.log(linkedwiki.addPropertyWithIri(project..'spectrum',spectrumIri))
   	 
   	spectrum =  linkedwiki.new(spectrumIri)
   	spectrum:removeSubject()
   	mw.log(spectrum:addPropertyWithIri(rdf..'type',project..'Spectrum'))
   	
   	 local AutomaticScript = "Manual"

	if not linkedwiki.isEmpty(f.args['Script pretreatment matlab']) then
		mw.log(spectrum:addPropertyWithIri(project..'scriptPretreatmentMatlab', filesDestination.."/"..f.args['Script pretreatment matlab']))
	end
	if not linkedwiki.isEmpty(f.args['Script spectral matrix generation matlab']) then
		mw.log(spectrum:addPropertyWithIri(project..'scriptSpectralMatrixGenerationMatlab',  filesDestination.."/"..f.args['Script spectral matrix generation matlab']))
	end
	if not linkedwiki.isEmpty(f.args['Script automatic']) then
		if f.args['Script automatic'] == "true" then
			mw.log(spectrum:addProperty(project..'scriptAutomatic', f.args['Script automatic'],xsd..'boolean'))
			AutomaticScript = "Automatic"
		end
	end
	if not linkedwiki.isEmpty(f.args.Matrix) then
		mw.log(spectrum:addPropertyWithIri(project..'matrix',  filesDestination.."/"..f.args.Matrix))
	end
	
	result = "* Spectrum"..f.args.Id.." ["..filesDestination.."/"..f.args.Matrix.." "..GetFileName(filesDestination.."/"..f.args.Matrix).."] ("..AutomaticScript.." scripts: ["..filesDestination.."/"..f.args['Script pretreatment matlab'].." pretreatment] ["..filesDestination.."/"..f.args['Script spectral matrix generation matlab'].." generation])"

	local listMeasures = linkedwiki.explode(",", f.args.Measures)
    for i, iri in ipairs(listMeasures) do
    	local iriTrim =  mw.text.trim(iri)
     		result = result .."\n** ["..filesDestination.."/"..iriTrim.." ".. GetFileName(filesDestination.."/"..iriTrim) .."]"
     		mw.log(spectrum:addPropertyWithIri(project..'hasMeasure',filesDestination.."/"..iriTrim))
    end
end

	return result
end

function p.SpectrumImage(f)
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   -- local urlFolder = 'file:///z:/'
   -- local iriFolder = 'file:///filer.ups.u-psud.fr/archivagesciences/'
   local dateFormat = "d M Y"
    
    --prefix
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local daap = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Individual'
   local daapProp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Property:'
   local geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
   local vcard = 'http://www.w3.org/2006/vcard/ns#'
   local xsd = 'http://www.w3.org/2001/XMLSchema#'

 -- save data 
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
   local campaign =  linkedwiki.new(subject)
   local spectrum = nil


mw.log(campaign:addPropertyWithIri(rdf..'type',project..'SpectrumImageCampaign'))
local result = ''
local spectrumIri = ''

if not linkedwiki.isEmpty(f.args.Id) then
	spectrumIri =  subject..'/SpectrumImage'..f.args.Id
	
   	mw.log(linkedwiki.addPropertyWithIri(project..'hasSpectrumImage',spectrumIri))
   	 
   	spectrum =  linkedwiki.new(spectrumIri)
   	spectrum:removeSubject()
   	mw.log(spectrum:addPropertyWithIri(rdf..'type',project..'SpectrumImage'))
   	
   	 local AutomaticScript = "Manual"

	if not linkedwiki.isEmpty(f.args['Script pretreatment matlab']) then
		mw.log(spectrum:addPropertyWithIri(project..'scriptPretreatmentMatlab', f.args['Script pretreatment matlab']))
	end
	if not linkedwiki.isEmpty(f.args['Script spectral matrix generation matlab']) then
		mw.log(spectrum:addPropertyWithIri(project..'scriptSpectralMatrixGenerationMatlab', f.args['Script spectral matrix generation matlab']))
	end
	if not linkedwiki.isEmpty(f.args['Script automatic']) then
		if f.args['Script automatic'] == "true" then
			mw.log(spectrum:addProperty(project..'scriptAutomatic', f.args['Script automatic'],xsd..'boolean'))
			AutomaticScript = "Automatic"
		end
	end
	if not linkedwiki.isEmpty(f.args.Matrix) then
		mw.log(spectrum:addPropertyWithIri(project..'matrix', f.args.Matrix))
	end
	
	result = "* SpectrumImage"..f.args.Id.." ["..f.args.Matrix.." "..GetFileName(f.args.Matrix).."] ("..AutomaticScript.." scripts: ["..f.args['Script pretreatment matlab'].." pretreatment] ["..f.args['Script spectral matrix generation matlab'].." generation])"

	if not linkedwiki.isEmpty(f.args['Measure']) then
		mw.log(spectrum:addPropertyWithIri(project..'measure', f.args['Measure']))
		result = result .."\n** [".. f.args['Measure'].." ".. GetFileName( f.args['Measure']) .."]"
	end
end

	return result
end

function p.Template(f)
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
	return '[['..tostring(linkedwiki.getCurrentTitle())..'/SlideInCampaign'..f.args.Medium..'|Modèle '..f.args.Medium..']]'
end

function p.Slide(f)
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   local subject = f.args.iri or linkedwiki.getCurrentIRI();

   
    local campaign =  linkedwiki.new(subject)
    local filesDestination= campaign:getValue(daapp..'filesFinalDestination')
    local dateStr = f.args.Date
	local medium = f.args['Medium'];
	local idSlide = f.args['Slide id'];
	local nbCell = f.args['Nb cell'];
	
	local labelSlide = string.format("%s_L%02d",medium,idSlide)
	local slideIri = subject.."/"..dateStr..labelSlide
	
	
	local labelSlideImage = string.format("%s%s_L%02d",dateStr,medium,idSlide)..'.jpg'
	local labelSlideImageIri = filesDestination..'/'..labelSlideImage
	
	local template= tostring(linkedwiki.getCurrentTitle())..'/SlideInCampaign'..medium
	local pageCellWithoutId= tostring(linkedwiki.getCurrentTitle())..'/SlideInCampaign'..labelSlide..'_cell'
	local iriCellWithoutId= tostring(linkedwiki.getCurrentIRI())..'/SlideInCampaign'..labelSlide..'_cell'
	
	mw.log(campaign:addPropertyWithIri(project..'hasSlide',slideIri))
    local slide =  linkedwiki.new(slideIri)
    slide:removeSubject();
    mw.log(slide:addPropertyWithIri(rdf..'type',project..'SlideInCampaign'))
    mw.log(slide:addPropertyString(rdfs..'label',labelSlide,""))
	mw.log(slide:addPropertyWithIri(project..'hasPicture', labelSlideImageIri))
	mw.log(slide:addPropertyWithIri(project..'celltype', project..'J774'))
	mw.log(slide:addPropertyWithIri(project..'medium', project..medium))
	
	
	
    local	result ='{| class="wikitable"\n'
	result = result .. '|rowspan="'..nbCell..'"| \'\'\''..labelSlide..'\'\'\' \n'
	result = result .. '|rowspan="'..nbCell..'"| ['..labelSlideImageIri..' '..labelSlideImage..'] \n'
	frame = mw.getCurrentFrame()
    local separator = ""
	for i=1,nbCell,1 
		do 
			local labeCell = string.format("%s_cell%02d",labelSlide,i)
			local pageCell = string.format("%s%02d",pageCellWithoutId,i)
			local iriCell = string.format("%s%02d",iriCellWithoutId,i)
			--slide:setDebug(true)
			mw.log(slide:addPropertyWithIri(project..'hasCell',iriCell))
			local cell = linkedwiki.new(iriCell)
			local typeCell= cell:getValue(rdf..'type')
			if  linkedwiki.isEmpty(typeCell) then
			   result =  result .. separator.. ' | '..  frame:callParserFunction( '#tag:inputbox', 
			[[type=create
	editintro=Create page
	preload=]]..template..[[ 
	hidden=yes
	default=]]..pageCell..[[ 
	buttonlabel=]]..labeCell..[[
			]] )..' \n'
	       else
	       	 result =  result .. separator.. ' | [['.. pageCell.."|"..labeCell.."]] \n"
	       end
		separator = "|- \n"
	end
	result = result .. '|} \n'
	
	return result
end



function p.addJ774InSlide(f)
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
    local cell =  linkedwiki.new(subject)
   	cell:removeSubject()
   	
    local dateStr = f.args.Date
	local medium = f.args['Medium'];
	local slideLabel = f.args['Slide'];
	local idCell = f.args['Cell ID'];
    local labelCell = string.format("%s%s_L%02d_cell%02d",dateStr,medium,slideLabel,idCell)
local labelCellImage = labelCell..'.jpg'

local iriCampaign = GetCampaignIri(subject)
 --mw.log(subject)
-- mw.log(iriCampaign)
local campaign =  linkedwiki.new(iriCampaign)
    local filesDestination= campaign:getValue(daapp..'filesFinalDestination')
    -- mw.log(filesDestination)
local iriCellImage = filesDestination.."/"..labelCellImage

    mw.log(cell:addPropertyWithIri(rdf..'type',project..'J774InSlide'))
    mw.log(cell:addPropertyString(rdfs..'label',labelCell,""))
	mw.log(cell:addPropertyWithIri(project..'hasPicture', iriCellImage))
	
	local result = '*Slide :'..slideLabel..' \n'
	result = result .. '*Date : '..dateStr..'  \n'
	result = result .. '*Medium : '..medium..' \n'
	result = result .. '*Cell Label : '..labelCell..'  \n'
	result = result .. '*Picture : ['..iriCellImage..' '..labelCellImage..'] \n'

	return result
end
 
function p.addMeasureInJ774Core(f)
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
    local cell =  linkedwiki.new(subject)
    local dateStr = f.args.Date
	local medium = f.args['Medium'];
	local slide = f.args['Slide'];
	local idCell = f.args['Cell ID'];
	local idPosition = f.args['Position ID'];
	
	
    local labelPosition = string.format("%s%s_L%02d_cell%02d_n%d",dateStr,medium,slide,idCell,idPosition)
local labelMeasure = labelPosition..'.spc'
local iriCampaign = GetCampaignIri(subject)
local campaign =  linkedwiki.new(iriCampaign)
local filesDestination= campaign:getValue(daapp..'filesFinalDestination')
local iriMeasure = filesDestination.."/"..labelMeasure

local positionIri = subject.."_n"..idPosition

    local cell =  linkedwiki.new(subject)
	mw.log(cell:addPropertyWithIri(project..'hasPosition', positionIri))
	local position =  linkedwiki.new(positionIri)
   	position:removeSubject()
    mw.log(position:addPropertyWithIri(rdf..'type',project..'MeasureInJ774Core'))
	mw.log(position:addPropertyWithIri(project..'hasMeasure', iriMeasure))
    mw.log(position:addPropertyString(rdfs..'label',labelPosition,""))
	
	local result =  '* n'..idPosition..'  : ['..iriMeasure..' '..labelMeasure..'] \n'

	return result
end

function p.addMeasureInJ774Cyto(f)
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
    local cell =  linkedwiki.new(subject)
    local dateStr = f.args.Date
	local medium = f.args['Medium'];
	local slide = f.args['Slide'];
	local idCell = f.args['Cell ID'];
	local idPosition = f.args['Position ID'];
	
	    local labelPosition = string.format("%s%s_L%02d_cell%02d_c%d",dateStr,medium,slide,idCell,idPosition)
local labelMeasure = labelPosition..'.spc'
local iriCampaign = GetCampaignIri(subject)
local campaign =  linkedwiki.new(iriCampaign)
local filesDestination= campaign:getValue(daapp..'filesFinalDestination')
local iriMeasure = filesDestination.."/"..labelMeasure

local positionIri = subject.."_c"..idPosition
    local cell =  linkedwiki.new(subject)
	mw.log(cell:addPropertyWithIri(project..'hasPosition', positionIri))
	local position =  linkedwiki.new(positionIri)
   	position:removeSubject()
    mw.log(position:addPropertyWithIri(rdf..'type',project..'MeasureInJ774Cytoplasm'))
	mw.log(position:addPropertyWithIri(project..'hasMeasure', iriMeasure))
    mw.log(position:addPropertyString(rdfs..'label',labelPosition,""))
	
	local result =  '* c'..idPosition..'  : ['..iriMeasure..' '..labelMeasure..'] \n'

	return result
end

function p.addCellMeasureJ774InSlide(f)
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
    local cell =  linkedwiki.new(subject)
   	cell:removeSubject()
   	
    local dateStr = f.args.Date
	local medium = f.args['Medium'];
	local slideLabel = f.args['Slide'];
	local idCell = f.args['Cell ID'];
    local labelCell = string.format("%s%s_L%02d_celli%s",dateStr,medium,slideLabel,idCell)
local labelCellImage = labelCell..'.jpg'
local labelCellMeasure = labelCell..'.spc'

local iriCampaign = GetCampaignIri(subject)
 --mw.log(subject)
-- mw.log(iriCampaign)
local campaign =  linkedwiki.new(iriCampaign)
    local filesDestination= campaign:getValue(daapp..'filesFinalDestination')
    -- mw.log(filesDestination)
local iriCellImage = filesDestination.."/"..labelCellImage
local iriCellMeasure = filesDestination.."/"..labelCellMeasure

    mw.log(cell:addPropertyWithIri(rdf..'type',project..'J774InSlide'))
    mw.log(cell:addPropertyString(rdfs..'label',labelCell,""))
	mw.log(cell:addPropertyWithIri(project..'hasPicture', iriCellImage))
	mw.log(cell:addPropertyWithIri(project..'hasMeasure', iriCellMeasure))

	local result = '*Slide :'..slideLabel..' \n'
	result = result .. '*Date : '..dateStr..'  \n'
	result = result .. '*Medium : '..medium..' \n'
	result = result .. '*Cell Label : '..labelCell..'  \n'
	result = result .. '*Picture : ['..iriCellImage..' '..labelCellImage..'] \n'
	result = result .. '*Measure : ['..iriCellMeasure..' '..labelCellMeasure..'] \n'
	return result
end

function p.Medium(f)
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local project = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Analyse_des_macrophages#'
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
   local subject = f.args.iri or linkedwiki.getCurrentIRI();

   
    local campaign =  linkedwiki.new(subject)
    local filesDestination= campaign:getValue(daapp..'filesFinalDestination')
    local dateStr = f.args.Date
	local medium = f.args['Medium'];
	local nbSpec = f.args['Nb Spectrums'];
	local typeMedium = f.args['Medium Type'];

	local labelMedium = string.format("%s_%s",medium,typeMedium)
	local mediumIri = subject.."/"..dateStr..labelMedium
	
	local labelMediumImage = string.format("%s%s_%s",dateStr,medium,typeMedium)..'.jpg'
	local labelMediumImageIri = filesDestination..'/'..labelMediumImage
	
	local template= tostring(linkedwiki.getCurrentTitle())..'/SlideInCampaign'..medium
	
	mw.log(campaign:addPropertyWithIri(project..'hasSlide',mediumIri))
    local slide =  linkedwiki.new(mediumIri)
    slide:removeSubject();
    mw.log(slide:addPropertyWithIri(rdf..'type',project..'Medium'))
    mw.log(slide:addPropertyString(rdfs..'label',labelMedium,""))
	mw.log(slide:addPropertyWithIri(project..'hasPicture', labelMediumImageIri))
	mw.log(slide:addPropertyWithIri(project..'medium', project..medium))
	
	
	
	
    local	result ='{| class="wikitable"\n'
	result = result .. '|rowspan="'..nbSpec..'"| ['..labelMediumImageIri..' '..labelMediumImage..'] \n'
	frame = mw.getCurrentFrame()
    local separator = ""
	for i=1,nbSpec,1 
		do 
			local labelMediumSpectrum = string.format("%s%s_%s%s",dateStr,medium,typeMedium,i)..'.spc'
			local labelMediumSpectrumIri = filesDestination..'/'..labelMediumSpectrum
			
			mw.log(slide:addPropertyWithIri(project..'hasMeasure', labelMediumSpectrumIri))
	       	result =  result .. separator.. ' | ['..labelMediumSpectrumIri..' '..labelMediumSpectrum.."] \n"
		separator = "|- \n"
	end
	result = result .. '|} \n'
	return result
end

return p